Setting Up Your Local Environment
From Joomla! Documentation
How to Setup a Local Environment for Joomla 4
With Joomla! 4 we have changed the development process. It is no longer possible to clone the repository and have a usable Joomla installation. We follow best practices and implement a build process for the CMS.
Quick Start Guide
The steps to setup your development environment depend on your operating system. We cannot write documentation for every operating system (OS), please use your favorite search engine to find a HowTo.
Tools You Need
- PHP - basically the same as you need for running a Joomla site, but you need the PHP CLI (command line interface) version. (See the Configuring a LAMPP server for PHP development page.)
- Composer - for managing Joomla's PHP dependencies. For help installing Composer, read the documentation at https://getcomposer.org/doc/00-intro.md.
- Git - for version management.
Steps to Setup the Local Environment
- Clone the repository.
- Run composer install from the root of the git repo. (You can add --ignore-platform-reqs if you don't have the PHP-LDAP locally installed and you don't need it.)
- Run npm ci from the root of the git repo. (Note you need npm 5.7 or higher for this. Run npm install -g npm@lts to upgrade your version of npm to the lts version.)
Linux and OSX users can set up the following bash alias by placing the following inside the ~/.bashrc file:
alias jclean="rm -rf administrator/templates/atum/css; rm -rf templates/cassiopeia/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"
This will delete all the compiled files in your system and run a fresh install as one command by calling jinstall inside your Joomla install. You can also use the jclean command to swap back to a Joomla 3.x branch
A Bit Longer Start Guide
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.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
npm run build:css
It will compile SASS files to CSS and also create the minified files.
npm run build:js
npm run watch:css
This is the same as the build:css command but will watch for changes and automatically build updated files.
npm run watch:js
This is the same as the build:js command but will watch for changes and automatically build updated files in the media directory.
npm run lint:js
npm run test