This guide will walk you through setting up and running the Sonata Extra Demo project locally.
Ensure your environment meets the following requirements:
- Docker: Docker and Docker Compose must be installed.
- Git: Required to clone the project repository.
Begin by cloning the repository from GitHub:
git clone https://github.com/partITech/sonata-extra-demo.git
cd sonata-extra-demo
Copy the environment configuration file and ensure the necessary values are set:
cp env.dist .env
By default, the following credentials are used for the database:
SQL_ROOT_PASSWORD=toor
SQL_DATABASE=sonata-extra-demo
SQL_USER=root
SQL_PASSWORD=toor
SQL_PORT=3306
Ensure that your .env
file contains the correct values or update them as necessary.
You can either use the pre-built Docker image or compile your own image using the provided Dockerfile. This Docker image is an "all-in-one" setup with everything required for the project. You can find the source Dockerfile at: Dockerfile.
To start and build the Docker containers, run:
docker-compose up --build
This will start all the necessary services:
www
: PHP application running Apache.db
: MariaDB for database.phpmyadmin
: PHPMyAdmin for database administration.mailcatcher
: Captures outgoing emails.
The MySQL data is stored in ./config/docker/data-sql/
, and the database can be automatically initialized by placing the SQL creation file in ./config/docker/init-sql/
. You can modify or comment out the following lines in the Docker configuration file to change this behavior:
db:
hostname: sonata_extra_demo_db
image: mariadb
ports:
- 3306:3306
command: --default-authentication-plugin=mysql_native_password
environment:
MYSQL_ROOT_PASSWORD: 'toor'
MYSQL_DATABASE: 'sonata-extra-demo'
MYSQL_USER: 'sonata'
MYSQL_PASSWORD: 'toor'
volumes:
- ./config/docker/data-sql/:/var/lib/mysql # MySQL data storage
- ./config/docker/init-sql/:/docker-entrypoint-initdb.d # Automatic database initialization
You don't need to do this if you moved the demo sql file in /config/docker/init-sql/
.
docker compose exec -T www mysql -h db -u root -ptoor sonata-extra-demo < sonata-extra-demo.sql
Once the containers are running, install the PHP dependencies:
docker compose exec -T www composer install
This step should be handled by composer install. Alternatively, you can execute these steps one by one.
This step installs the Gutenberg editor and the latest free version of CKEditor. If you have a valid licence for CKEditor, it is recommended to remove the --tag=4.19.0
option to install the latest licensed version.
docker compose exec -T www symfony console sonata:extra:install-gutenberg
docker compose exec -T www symfony console ckeditor:install --tag=4.19.0
docker compose exec -T www symfony console asset:install
Run the following commands to set up multilingual support for the demo and ensure correct routing:
docker compose exec -T www symfony console sonata:page:create-site --enabled --name France --relativePath /fr --host localhost --enabledFrom now --enabledTo 2030-10-18 --locale fr --default --no-confirmation
docker compose exec -T www symfony console sonata:page:create-site --enabled --name English --relativePath /en --host localhost --enabledFrom now --enabledTo 2030-10-18 --locale en --no-confirmation
docker compose exec -T www symfony console sonata:page:update-core-routes
docker compose exec -T www symfony console sonata:extra:page-fix-route
docker compose exec -T www symfony console sonata:page:create-snapshots
You can enable more lang. Simply run one or all these lines and re-run the update-core-routes
, page-fix-route
and create-snapshots
docker compose exec -T www symfony console sonata:page:create-site --enabled --name France --relativePath /fr --host localhost --enabledFrom now --enabledTo 2030-10-18 --locale fr --default --no-confirmation
docker compose exec -T www symfony console sonata:page:create-site --enabled --name Germany --relativePath /de --host localhost --enabledFrom now --enabledTo 2030-10-18 --locale de --no-confirmation
docker compose exec -T www symfony console sonata:page:create-site --enabled --name Spain --relativePath /es --host localhost --enabledFrom now --enabledTo 2030-10-18 --locale es --no-confirmation
docker compose exec -T www symfony console sonata:page:create-site --enabled --name Italy --relativePath /it --host localhost --enabledFrom now --enabledTo 2030-10-18 --locale it --no-confirmation
docker compose exec -T www symfony console sonata:page:create-site --enabled --name United Kingdom --relativePath /en --host localhost --enabledFrom now --enabledTo 2030-10-18 --locale en --no-confirmation
docker compose exec -T www symfony console sonata:page:create-site --enabled --name Portugal --relativePath /pt --host localhost --enabledFrom now --enabledTo 2030-10-18 --locale pt --no-confirmation
docker compose exec -T www symfony console sonata:page:create-site --enabled --name Belgium --relativePath /nl --host localhost --enabledFrom now --enabledTo 2030-10-18 --locale nl --no-confirmation
docker compose exec -T www symfony console sonata:page:create-site --enabled --name Netherlands --relativePath /nl --host localhost --enabledFrom now --enabledTo 2030-10-18 --locale nl --no-confirmation
docker compose exec -T www symfony console sonata:page:create-site --enabled --name Austria --relativePath /de --host localhost --enabledFrom now --enabledTo 2030-10-18 --locale de --no-confirmation
docker compose exec -T www symfony console sonata:page:create-site --enabled --name Switzerland --relativePath /fr --host localhost --enabledFrom now --enabledTo 2030-10-18 --locale fr --no-confirmation
docker compose exec -T www symfony console sonata:page:create-site --enabled --name Sweden --relativePath /sv --host localhost --enabledFrom now --enabledTo 2030-10-18 --locale sv --no-confirmation
docker compose exec -T www symfony console sonata:page:create-site --enabled --name Norway --relativePath /no --host localhost --enabledFrom now --enabledTo 2030-10-18 --locale no --no-confirmation
docker compose exec -T www symfony console sonata:page:create-site --enabled --name Finland --relativePath /fi --host localhost --enabledFrom now --enabledTo 2030-10-18 --locale fi --no-confirmation
docker compose exec -T www symfony console sonata:page:create-site --enabled --name Denmark --relativePath /da --host localhost --enabledFrom now --enabledTo 2030-10-18 --locale da --no-confirmation
docker compose exec -T www symfony console sonata:page:create-site --enabled --name Poland --relativePath /pl --host localhost --enabledFrom now --enabledTo 2030-10-18 --locale pl --no-confirmation
docker compose exec -T www symfony console sonata:page:create-site --enabled --name Czech Republic --relativePath /cz --host localhost --enabledFrom now --enabledTo 2030-10-18 --locale cz --no-confirmation
docker compose exec -T www symfony console sonata:page:create-site --enabled --name Slovakia --relativePath /sk --host localhost --enabledFrom now --enabledTo 2030-10-18 --locale sk --no-confirmation
docker compose exec -T www symfony console sonata:page:create-site --enabled --name Hungary --relativePath /hu --host localhost --enabledFrom now --enabledTo 2030-10-18 --locale hu --no-confirmation
docker compose exec -T www symfony console sonata:page:create-site --enabled --name Greece --relativePath /gr --host localhost --enabledFrom now --enabledTo 2030-10-18 --locale gr --no-confirmation
docker compose exec -T www symfony console sonata:page:create-site --enabled --name Ireland --relativePath /ie --host localhost --enabledFrom now --enabledTo 2030-10-18 --locale ie --no-confirmation
docker compose exec -T www symfony console sonata:page:create-site --enabled --name Luxembourg --relativePath /lu --host localhost --enabledFrom now --enabledTo 2030-10-18 --locale lu --no-confirmation
Create the Super Admin user. You can adjust the credentials as needed:
docker-compose exec www symfony console sonata:user:create --super-admin admin [email protected] demo
To access the admin panel, use the following credentials:
- URL:
http://localhost/fr/admin/login
- Login:
admin
- Password:
demo
To change the password of any user, use the following command:
docker-compose exec www php bin/console sonata:user:change-password admin new_password
Once the setup is complete, the demo application is accessible at:
http://localhost
You should be able to see the homepage and switch between French and English using the language selector.
Manage the database using PHPMyAdmin at:
http://localhost:8081
Login credentials:
- Server:
db
- Username:
root
- Password:
toor
- Port:
3306
These credentials are from your .env
file.
The server adress and port is the name of the db container from your docker configuration.
To view captured outgoing emails, access Mailcatcher at:
http://localhost:1080
The configuration in the .env
file is:
MAILER_DSN=smtp://localhost:1025
If you encounter any issues:
- Ensure Docker and Docker Compose are properly running.
- Verify that the
.env
file is configured correctly. - Check for container errors using
docker-compose logs
. - Always remember to run
sonata:extra:page-fix-route
after creating a new site or a new route to ensure the relations between routes and languages are correctly established.
We welcome contributions! Submit your Pull Requests for improvements, bug fixes, unit tests, and new features. Contributions to the documentation are also appreciated.
Enjoy using Sonata Extra Demo!