Configuración de su Entorno Local
From Joomla! Documentation
Cómo configurar un Entorno Local para Joomla 4
Con Joomla! 4 hemos cambiado el proceso de desarrollo. Ya no es posible clonar el repositorio y tener una instalación de Joomla utilizable. Seguimos las mejores prácticas e implementamos un proceso de construcción para el CMS.
Guía de Inicio Rápido
Los pasos para configurar su entorno de desarrollo dependen de su sistema operativo. No podemos escribir documentación para todos los sistemas operativos (SO), utilice su motor de búsqueda favorito para encontrar un HowTo.
Herramientas que necesita
- PHP: básicamente lo mismo que necesita para ejecutar un sitio Joomla, pero necesita la versión PHP CLI (interfaz de línea de comandos). (Consulte la página Configuración de un servidor LAMPP para el desarrollo de PHP).
- Composer - para administrar las dependencias PHP de Joomla. Para obtener ayuda con la instalación de Composer, lea la documentación en https://getcomposer.org/doc/00-intro.md (en Inglés).
- Node.js: para compilar archivo JavaScript y SASS de Joomla. Para obtener ayuda con la instalación de Node.js, siga las instrucciones disponibles en https://nodejs.org/en/. Tenga en cuenta que necesitarás NodeJS 12 o superior para instalar Joomla.
- Git - para la gestión de versiones.
Pasos para Configurar el Entorno Local
- Clonar el repositorio
- Checkout de la rama 4.0-dev
- Ejecutar composer install desde la raiz del repositorio git. (Puede agregar --ignore-platform-reqs si no tiene PHP-LDAP instalado localmente y no lo necesita)
- Ejecutar npm ci desde la raiz del repositorio git. (Tenga en cuenta que necesita npm 6.13.4 o superior para esto. Ejecutar npm install -g npm@lts para actualizar su versión de npm a la versión LTS).
Los usuarios de Linux y OSX pueden configurar el siguiente alias de bash colocando lo siguiente dentro del archivo ~/.bashrc file:
alias jclean="rm -rf administrator/templates/atum/css; rm -rf templates/cassiopeia/css; rm -rf administrator/templates/system/css; rm -rf templates/system/css; rm -rf media/; rm -rf node_modules/; rm -rf libraries/vendor/;rm -f administrator/cache/autoload_psr4.php;rm -rf installation/template/css"
alias jinstall="jclean; composer install; npm ci"
Esto eliminará todos los archivos compilados en su sistema y ejecutará una nueva instalación como un comando llamando a jinstall dentro de su instalación de Joomla. También puede usar el comando jclean para volver a una rama de Joomla 3.x
Una guía de inicio un poco más larga
Joomla is similar to many other web tools these days. It has a large PHP part and it has more and more JavaScript code. While PHP coding doesn't need so much preparation, JavaScript needs a lot tooling around. The main reason is that nobody writes code in a way that every browser understands, so the code needs transpiling from e.g. ES6 to a compatible version of JavaScript. The same is true for CSS. For Joomla we are using SASS and this will be converted to native CSS so that any browser understands it. On the downside, setting up a development environment is a bit more complicated but the tooling makes coding more convenient. Thanks to watchers and browser auto reload, you can see your changes in real time.
PHP
It should be enough to run composer install as this will install PHP dependencies saved in the composer.lock file. You can do this as many times as you like. It will only install new packages when the composer.lock file is changed. Don't run composer update as this will update all packages to newer versions and update the composer.lock file.
Note: You may need to run composer install with the --ignore-platform-reqs option to ignore platform requirements specified in Composer. That is, if you do not have PHP's LDAP extension installed.
Node/npm Scripts
Node.js comes with a package manager called NPM (in some ways the same as Composer). NPM has a run command and we have prepared some scripts to make your life easier. You have to run the commands for the root of the repository when you changed JS or SASS files. Previously you need to run npm ci once, to install dependencies.
npm run build:css
It will compile SASS files to CSS and also create the minified files.
npm run build:js
It will compile and transpile the JavaScript files to the correct format and create minified files.
npm run watch
This is the same as the build:js command but will watch for changes and automatically build updated files in the media directory. SASS files are not included yet.
npm run lint:js
This will perform a syntax check on all ES6 JavaScript files against the javascript code standard (for more information on the Joomla 4 codestyle standard please read the the coding standards manual at the coding standards manual.
npm run test
This will run a JavaScript testing suite.
Possible Issues
When running composer install you can run into these errors
Problem 1
- Installation request for joomla/ldap 2.0.0-beta -> satisfiable by joomla/ldap[2.0.0-beta].
- joomla/ldap 2.0.0-beta requires ext-ldap * -> the requested PHP extension ldap is missing from your system.
Problem 2
- Installation request for symfony/ldap v5.1.5 -> satisfiable by symfony/ldap[v5.1.5].
- symfony/ldap v5.1.5 requires ext-ldap * -> the requested PHP extension ldap is missing from your system.
The solution is to run the composer install with the --ignore-platform-reqs option to ignore platform requirements specified in Composer. That is, if you do not have PHP's LDAP extension installed.
composer install --ignore-platform-reqs
If you receive a login error such as shown below, delete the library/autoload_psr4.php file as shown in the second image.