B1 first commit, example
This commit is contained in:
114
README.md
Normal file
114
README.md
Normal file
@ -0,0 +1,114 @@
|
||||
# Depot
|
||||
|
||||
## Introduction
|
||||
|
||||
This project is also based on the desperation to sort and find my electronic
|
||||
components. Some integrated circuits (ICs) accumulated in various boxes and
|
||||
the question of whether I own that or the other IC, had to be painstakingly
|
||||
researched. Above all, there were at one time several places where components
|
||||
were stored or partly kept at a plant.
|
||||
The idea was born, but it took long time to implement it.
|
||||
Klosterneuburg, October 2023 Thomas Kuschel KW4NZ.
|
||||
|
||||
## Workflow (since 0.0.1)
|
||||
|
||||
In git we start to make a new branch named b1_basic_backend, where we start
|
||||
developing our project. The first run with simply renaming entries from a
|
||||
copy of the component **com_banners** did not work as expected.
|
||||
So let us start at the very beginning:
|
||||
|
||||
### Adding basic files for component (b1_basic_backend)
|
||||
|
||||
With the git branch **b1_basic_backend**
|
||||
Add the following basic six files:
|
||||
|
||||
1. admin
|
||||
|
||||
- src/Extension/DepotComponent.php: The main extension file for the component.
|
||||
- services/provider.php: It tells Joomla how to initialize or boot the component.
|
||||
- src/Controller/DisplayController.php: The default Controller for the component.
|
||||
- src/View/Parts/HtmlView.php: The Html View for the "Parts" page.
|
||||
- tmpl/parts/default.php: The layout file for the "Parts" page.
|
||||
|
||||
2. depot.xml: XML manifest file that tells Joomla! how to install the component.
|
||||
|
||||
#### Description of each file:
|
||||
|
||||
##### 1. DepotComponent.php
|
||||
This file contains class for the extension. The class extends MVCComponent.
|
||||
|
||||
##### 2. provider.php
|
||||
This is a special file that tells Joomla how to initialize the component - which
|
||||
services it requires and how they should be provided.
|
||||
|
||||
The service provider file registers dependencies the component will use.
|
||||
Here, we have included two dependencies:
|
||||
|
||||
- **DispatcherFactory** is needed to create the Dispatcher class instance,
|
||||
and then Joomla will call dispatch() on this Dispatcher object, as the
|
||||
next step in running the component.
|
||||
|
||||
- **MVCFactory** is needed to create the Controller, View, Model and Table class
|
||||
instances on behalf of the component.
|
||||
|
||||
|
||||
##### 3. DisplayController.php
|
||||
This is a **default controller** for the component. It simply sets its default
|
||||
view and leaves the rest to its parent.
|
||||
|
||||
When you view the component through URL, Joomla uses the **controller** to execute
|
||||
the **task**. The task is the name of method in the controller file.
|
||||
If you do not pass the controller or task in the URL, it defaults to Display
|
||||
Controller and display Task.
|
||||
|
||||
The default view is the name of the component. So, here we need to override the
|
||||
default view to `parts`.
|
||||
|
||||
##### 4. HtmlView.php
|
||||
This file contains class HtmlView that extends BaseHtmlView. The BaseHtmlView is
|
||||
the base class for a Joomla View.
|
||||
|
||||
The **view gets the data from the model to be output by the layout file.**
|
||||
|
||||
For example:
|
||||
```php
|
||||
$this->msg = $this->get('Msg');
|
||||
```
|
||||
|
||||
This method converts the get('Msg') call into a getMsg() call on the model, which
|
||||
is the method which you have to provide in the model.
|
||||
|
||||
The view file displays data using the template layout file - $tpl, which defaults
|
||||
to default.php.
|
||||
|
||||
##### 5. default.php
|
||||
This file holds the template for the page. When no specific layout is
|
||||
requested for a view, Joomla will load the template in the **default.php** file.
|
||||
|
||||
```php
|
||||
<h2>Welcome to Depot Component!</h2>
|
||||
```
|
||||
|
||||
##### 6. depot.xml
|
||||
This file tells Joomla how to install the component and what file are included.
|
||||
|
||||
In the administration part, we include a link to the menu and include files
|
||||
and folders (services, src, tmpl and so on) which are in the parent folder
|
||||
admin of the component. While installing the component, these will get copied
|
||||
to the Joomla administrator/components/com_depot.
|
||||
|
||||
#### Installation the component
|
||||
Create a **.zip** file of the com_depot directory. Then inside the Joomla
|
||||
Administration upload this .zip package.
|
||||
|
||||
Now you should see a new link "Depot" in the "Compnents" section of the menu.
|
||||
If you click it, you should see the default "Depot" page.
|
||||
|
||||
#### Language files
|
||||
We create two language files for the system and the component **Depot** at
|
||||
the directory /admin/language/en-GB/ naming it
|
||||
|
||||
- com_depot.ini
|
||||
- com_depot.sys.ini
|
||||
|
||||
---
|
Reference in New Issue
Block a user