Compare commits
No commits in common. "8e677c05f369a1d9194bcba2509074ca16c54773" and "985514c51b32761cfa5f9226a67b5df8ddc47e17" have entirely different histories.
8e677c05f3
...
985514c51b
52
README.md
52
README.md
@ -4,44 +4,17 @@ Joomla CMS.
|
|||||||
|
|
||||||
Make sure the projectName is set correctly, it's very important, because it's used for git, docker, mysql and joomla.
|
Make sure the projectName is set correctly, it's very important, because it's used for git, docker, mysql and joomla.
|
||||||
|
|
||||||
## Quick Installation
|
## Installation
|
||||||
|
1. Clone me ```git clone git@git.nickyeoman.com:nick/joomla.git projectName```
|
||||||
|
1. cd projectName
|
||||||
|
1. Setup your .env file ```mv env.sample .env``` then edit with your favorite editor.
|
||||||
|
1. Prepare your project for git ```bash bin/new_project.sh```
|
||||||
|
1. Run the containers to initialize ```sudo bash bin/docker_up.sh```
|
||||||
|
1. cli installer ```bash bin/setup_joomla_installer.sh```
|
||||||
|
1. Manually set Site Meta Description in [Administrator](http://localhost:8000/administrator/index.php?option=com_config)
|
||||||
|
1. Run ```sudo bash bin/finalize.sh```
|
||||||
|
|
||||||
```bash
|
## Working Environment
|
||||||
# STEP 1
|
|
||||||
# Clone the repo (change projectName to the name of your project)
|
|
||||||
git clone git@git.nickyeoman.com:nick/joomla.git projectName
|
|
||||||
|
|
||||||
# STEP 2
|
|
||||||
# Move into the dir
|
|
||||||
cd projectName
|
|
||||||
|
|
||||||
# STEP 3
|
|
||||||
# Setup your env file
|
|
||||||
mv env.sample .env
|
|
||||||
vi .env
|
|
||||||
|
|
||||||
# STEP 4
|
|
||||||
# Prepare your project for git
|
|
||||||
bash bin/new_project.sh
|
|
||||||
|
|
||||||
# STEP 5
|
|
||||||
# Run the containers to initialize
|
|
||||||
sudo bash bin/docker_up.sh
|
|
||||||
|
|
||||||
# STEP 6
|
|
||||||
# Joomla cli installer
|
|
||||||
sudo bash bin/setup_joomla_installer.sh
|
|
||||||
|
|
||||||
# STEP 7
|
|
||||||
# Manually set Site Meta Description in [Administrator](http://localhost:8000/administrator/index.php?option=com_config)
|
|
||||||
|
|
||||||
# Step 8
|
|
||||||
# Clean up and Config
|
|
||||||
sudo bash bin/finalize.sh
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
## Development Environment
|
|
||||||
|
|
||||||
Let's update our bash_profile with some alias:
|
Let's update our bash_profile with some alias:
|
||||||
```bash
|
```bash
|
||||||
@ -62,7 +35,6 @@ joomla cache:clean
|
|||||||
1. Move to the directory where you would like to keep the component. ```cd ~/joomla-components/```
|
1. Move to the directory where you would like to keep the component. ```cd ~/joomla-components/```
|
||||||
1. Run component creator from your Joomla install. ```bash ~/projects/joomla/projectName/bin/create_component.sh```
|
1. Run component creator from your Joomla install. ```bash ~/projects/joomla/projectName/bin/create_component.sh```
|
||||||
1. Optionally save to git repo.
|
1. Optionally save to git repo.
|
||||||
1. build the zip file by running bin/build_component.sh
|
|
||||||
|
|
||||||
## References
|
## References
|
||||||
|
|
||||||
@ -72,7 +44,7 @@ joomla cache:clean
|
|||||||
|
|
||||||
* https://github.com/ceford/j4xdemos-com-mywalks/tree/master
|
* https://github.com/ceford/j4xdemos-com-mywalks/tree/master
|
||||||
* https://www.abdulwaheed.pk/en/blog/41-information-technology/44-joomla/302-how-to-create-joomla-4-component.html
|
* https://www.abdulwaheed.pk/en/blog/41-information-technology/44-joomla/302-how-to-create-joomla-4-component.html
|
||||||
* Can't get this one working either: https://www.techfry.com/resources/how-to-create-joomla-component
|
* https://www.techfry.com/resources/how-to-create-joomla-component
|
||||||
* https://docs.joomla.org/J4.x:Developing_an_MVC_Component/Introduction
|
* https://docs.joomla.org/J4.x:Developing_an_MVC_Component/Introduction
|
||||||
* Can't get this one working [Develop a component](https://docs.joomla.org/J4.x:Developing_an_MVC_Component/Developing_a_Basic_Component)
|
* [Develop a component](https://docs.joomla.org/J4.x:Developing_an_MVC_Component/Developing_a_Basic_Component)
|
||||||
* [Minimal component](https://joomla.stackexchange.com/questions/22176/minimal-basic-structure-for-a-frontend-joomla-component-without-using-joomla-mvc)
|
* [Minimal component](https://joomla.stackexchange.com/questions/22176/minimal-basic-structure-for-a-frontend-joomla-component-without-using-joomla-mvc)
|
16
bin/component_parts/admin_controller.sh
Normal file
16
bin/component_parts/admin_controller.sh
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
cat <<EOM
|
||||||
|
<?php
|
||||||
|
defined('_JEXEC') or die;
|
||||||
|
|
||||||
|
use Joomla\CMS\MVC\Controller\AdminController;
|
||||||
|
|
||||||
|
class ${name^}Controller extends AdminController
|
||||||
|
{
|
||||||
|
public function __construct(\$config = array())
|
||||||
|
{
|
||||||
|
parent::__construct(\$config);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOM
|
16
bin/component_parts/admin_controller_base.sh
Normal file
16
bin/component_parts/admin_controller_base.sh
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
cat <<EOM > admin_controller_base.php
|
||||||
|
<?php
|
||||||
|
defined('_JEXEC') or die;
|
||||||
|
|
||||||
|
use Joomla\CMS\MVC\Controller\Controller;
|
||||||
|
|
||||||
|
class ${name^}Controller extends Controller
|
||||||
|
{
|
||||||
|
public function __construct(\$config = array())
|
||||||
|
{
|
||||||
|
parent::__construct(\$config);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOM
|
@ -1,14 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Check if $name is set
|
|
||||||
if [[ -z "${name}" ]]; then
|
|
||||||
echo "Error: Variable \$name is not set. Exiting (displaycontroller.sh)."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
cat <<EOM > admin/tmpl/${name}/default.php
|
|
||||||
<?php defined('_JEXEC') or die('Restricted Access'); ?>
|
|
||||||
|
|
||||||
<h2>Hello ${name}!</h2>
|
|
||||||
|
|
||||||
EOM
|
|
@ -1,29 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Check if $name is set
|
|
||||||
if [[ -z "${name}" ]]; then
|
|
||||||
echo "Error: Variable \$name is not set. Exiting (displaycontroller.sh)."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
cat <<EOM > admin/src/Controller/DisplayController.php
|
|
||||||
<?php
|
|
||||||
namespace Harvst\\Component\\${name^}\\Administrator\\Controller;
|
|
||||||
|
|
||||||
defined('_JEXEC') or die;
|
|
||||||
|
|
||||||
use Joomla\CMS\MVC\Controller\BaseController;
|
|
||||||
|
|
||||||
class DisplayController extends BaseController {
|
|
||||||
|
|
||||||
protected \$default_view = '${name}';
|
|
||||||
|
|
||||||
public function display(\$cachable = false, \$urlparams = array()) {
|
|
||||||
return parent::display(\$cachable, \$urlparams);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
EOM
|
|
||||||
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
current_date=$(date +'%B %Y')
|
current_date=$(date +'%B %Y')
|
||||||
current_year=$(date +'%Y')
|
|
||||||
# Check if JOOMLA_USER is set, otherwise prompt for it
|
# Check if JOOMLA_USER is set, otherwise prompt for it
|
||||||
if [ -z "$JOOMLA_USER" ]; then
|
if [ -z "$JOOMLA_USER" ]; then
|
||||||
read -p "Enter the Joomla user: " JOOMLA_USER
|
read -p "Enter the Joomla user: " JOOMLA_USER
|
||||||
@ -15,34 +15,29 @@ fi
|
|||||||
cat <<EOM > ${name}.xml
|
cat <<EOM > ${name}.xml
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<extension type="component" method="upgrade">
|
<extension type="component" method="upgrade">
|
||||||
<name>${name}</name>
|
<name>com_${name}</name>
|
||||||
<creationDate>${current_date}</creationDate>
|
<creationDate>${current_date}</creationDate>
|
||||||
<author>${JOOMLA_USER}</author>
|
<author>${JOOMLA_USER}</author>
|
||||||
<authorEmail>${EMAIL}</authorEmail>
|
<authorEmail>${EMAIL}</authorEmail>
|
||||||
<authorUrl>https://www.example.com/</authorUrl>
|
<authorUrl>https://www.example.com/</authorUrl>
|
||||||
<copyright>Copyright (C) ${current_year} ${JOOMLA_USER}, All rights reserved.</copyright>
|
<copyright>Copyright (C) 2023 ${JOOMLA_USER}, All rights reserved.</copyright>
|
||||||
<license>GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html</license>
|
<license>GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html</license>
|
||||||
|
|
||||||
|
<!-- The version string is recorded in the components table -->
|
||||||
<version>0.0.1</version>
|
<version>0.0.1</version>
|
||||||
|
|
||||||
<!-- The description is optional and defaults to the name -->
|
<!-- The description is optional and defaults to the name -->
|
||||||
<description>COM_${name^^}_DESCRIPTION</description>
|
<description>COM_${name^^}_DESCRIPTION</description>
|
||||||
|
|
||||||
<namespace path="src/">Harvst\Component\\${name^}</namespace>
|
<namespace path="src">harvst\Component\com_${name}</namespace>
|
||||||
|
|
||||||
<administration>
|
<administration>
|
||||||
<!-- The link that will appear in the Admin panel's "Components" menu -->
|
<!-- The link that will appear in the Admin panel's "Components" menu -->
|
||||||
<menu link="index.php?option=com_${name}">${name^}</menu>
|
<menu link="index.php?option=com_${name}">${name}</menu>
|
||||||
<files folder="admin">
|
<files folder="admin">
|
||||||
<folder>language</folder>
|
<folder>language</folder>
|
||||||
<folder>services</folder>
|
|
||||||
<folder>src</folder>
|
|
||||||
<folder>tmpl</folder>
|
|
||||||
</files>
|
</files>
|
||||||
<languages folder="admin">
|
|
||||||
<!-- TODO: It's there but not working -->
|
|
||||||
<language tag="en-GB">language/en-GB/en-GB.com_${name}.ini</language>
|
|
||||||
</languages>
|
|
||||||
</administration>
|
</administration>
|
||||||
</extension>
|
</extension>
|
||||||
EOM
|
EOM
|
||||||
|
@ -1,35 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
cat <<EOM > admin/services/provider.php
|
|
||||||
|
|
||||||
<?php defined('_JEXEC') or die;
|
|
||||||
|
|
||||||
use Joomla\CMS\Dispatcher\ComponentDispatcherFactoryInterface;
|
|
||||||
use Joomla\CMS\Extension\ComponentInterface;
|
|
||||||
use Joomla\CMS\Extension\MVCComponent;
|
|
||||||
use Joomla\CMS\Extension\Service\Provider\ComponentDispatcherFactory;
|
|
||||||
use Joomla\CMS\Extension\Service\Provider\MVCFactory;
|
|
||||||
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
|
|
||||||
use Joomla\DI\Container;
|
|
||||||
use Joomla\DI\ServiceProviderInterface;
|
|
||||||
|
|
||||||
return new class implements ServiceProviderInterface {
|
|
||||||
|
|
||||||
public function register(Container \$container): void {
|
|
||||||
\$container->registerServiceProvider(new MVCFactory('\\\\Harvst\\\\Component\\\\${name^}'));
|
|
||||||
\$container->registerServiceProvider(new ComponentDispatcherFactory('\\\\Harvst\\\\Component\\\\${name^}'));
|
|
||||||
\$container->set(
|
|
||||||
ComponentInterface::class,
|
|
||||||
function (Container \$container) {
|
|
||||||
\$component = new MVCComponent(\$container->get(ComponentDispatcherFactoryInterface::class));
|
|
||||||
\$component->setMVCFactory(\$container->get(MVCFactoryInterface::class));
|
|
||||||
|
|
||||||
return \$component;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
EOM
|
|
||||||
|
|
||||||
|
|
16
bin/component_parts/site_controller.sh
Normal file
16
bin/component_parts/site_controller.sh
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
cat <<EOM
|
||||||
|
<?php
|
||||||
|
defined('_JEXEC') or die;
|
||||||
|
|
||||||
|
use Joomla\CMS\MVC\Controller\BaseController;
|
||||||
|
|
||||||
|
class ${name^}Controller extends BaseController
|
||||||
|
{
|
||||||
|
public function __construct(\$config = array())
|
||||||
|
{
|
||||||
|
parent::__construct(\$config);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOM
|
16
bin/component_parts/site_controller_base.sh
Normal file
16
bin/component_parts/site_controller_base.sh
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
cat <<EOM
|
||||||
|
<?php
|
||||||
|
defined('_JEXEC') or die;
|
||||||
|
|
||||||
|
use Joomla\CMS\MVC\Controller\Controller;
|
||||||
|
|
||||||
|
class ${name^}Controller extends Controller
|
||||||
|
{
|
||||||
|
public function __construct(\$config = array())
|
||||||
|
{
|
||||||
|
parent::__construct(\$config);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOM
|
@ -1,26 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Check if $name is set
|
|
||||||
if [[ -z "${name}" ]]; then
|
|
||||||
echo "Error: Variable \$name is not set. Exiting (displaycontroller.sh)."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
cat <<EOM > admin/src/View/${name^}/HtmlView.php
|
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Harvst\\Component\\${name^}\\Administrator\\View\\${name^};
|
|
||||||
|
|
||||||
defined('_JEXEC') or die;
|
|
||||||
|
|
||||||
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
|
||||||
|
|
||||||
class HtmlView extends BaseHtmlView {
|
|
||||||
|
|
||||||
function display(\$tpl = null) {
|
|
||||||
parent::display(\$tpl);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
EOM
|
|
@ -1,5 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# create_component.sh componentName
|
|
||||||
|
|
||||||
# Determine the directory where the script is located
|
# Determine the directory where the script is located
|
||||||
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
|
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
|
||||||
@ -57,17 +56,17 @@ mkdir -p "$component_dir"
|
|||||||
# Create the main component files
|
# Create the main component files
|
||||||
cd "$component_dir" || exit
|
cd "$component_dir" || exit
|
||||||
mkdir -p site
|
mkdir -p site
|
||||||
mkdir -p admin/language/en-GB admin/services
|
mkdir -p admin/language/en-GB
|
||||||
mkdir -p admin/src/Controller admin/src/View/${name^} admin/tmpl/${name}
|
|
||||||
|
|
||||||
# Source the files for generating component files
|
# Source the files for generating component files
|
||||||
source "$script_dir/component_parts/manifest.sh"
|
source "$script_dir/component_parts/manifest.sh"
|
||||||
source "$script_dir/component_parts/language.sh"
|
source "$script_dir/component_parts/language.sh"
|
||||||
source "$script_dir/component_parts/provider.sh"
|
# source "$script_dir/component_parts/admin_controller.sh"
|
||||||
source "$script_dir/component_parts/displaycontroller.sh"
|
# source "$script_dir/component_parts/site_controller.sh"
|
||||||
source "$script_dir/component_parts/view.sh"
|
# source "$script_dir/component_parts/site_controller_base.sh"
|
||||||
source "$script_dir/component_parts/defaultview.sh"
|
# source "$script_dir/component_parts/admin_controller_base.sh"
|
||||||
|
|
||||||
|
|
||||||
echo "Component framework generated successfully!"
|
echo "Component framework generated successfully!"
|
||||||
echo "You should manually edit the manifest file before checkin"
|
echo "You should manually edit the manifest file before checkin"
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ services:
|
|||||||
- joomla-db:/var/lib/mysql
|
- joomla-db:/var/lib/mysql
|
||||||
|
|
||||||
joomla:
|
joomla:
|
||||||
image: joomla:4.3.2 # https://hub.docker.com/_/joomla
|
image: joomla:4.3.1 # https://hub.docker.com/_/joomla
|
||||||
restart: always
|
restart: always
|
||||||
environment:
|
environment:
|
||||||
JOOMLA_DB_HOST: mariadb
|
JOOMLA_DB_HOST: mariadb
|
||||||
|
Reference in New Issue
Block a user