- Version Symfony 7.0.*
This project is a template for creating a Symfony application using the hexagonal architecture. It is based on the php-ddd-example project, but with some changes and improvements.
- Clone the repository from GitHub.
git clone https://github.com/tonicarreras/symfony-base.git
- Build and run the Docker containers (Makefile).
# Build and run Docker containers
make install
- JWT PEM
## Recommended: With passphrase
make jwt-pp-config
# Without passphrase
make jwt-config
- Terminal
# Enter the Docker container's terminal
make sh
- Database MySql (MariaDB)
- Database: symfony-database
- user: root
- password: root
- Access the application
You can access the application in your web browser at:
- PHP 8.3 or higher
- Composer
- MySQL or MariaDB
- Symfony CLI (optional)
Important
This project requires the following PHP extensions to be installed and enabled:
- ext-ctype: Used for character type checking.
- ext-iconv: For character encoding conversion.
- ext-pdo: Essential for PHP Data Object (PDO) database connections.
- Install dependencies:
composer install
- Database migrations:
You will need to configure the database connection by modifying the DATABASE_URL in the .env file to match your MySQL settings.
php bin/console doctrine:migrations:migrate
- JWT PEM
Important
LexikJWTAuthenticationBundle requires a private and public key to sign and verify the JWT token. JWT_PASSPHRASE=your_secret_passphrase on .env file. This is to protect /api routes with JWT authentication.
## Recommended: With passphrase
mkdir -p config/jwt
openssl genrsa -out config/jwt/private.pem -aes256 4096
openssl rsa -pubout -in config/jwt/private.pem -out config/jwt/public.pem
# Without passphrase
mkdir -p config/jwt
openssl genrsa -out config/jwt/private.pem 4096
openssl rsa -pubout -in config/jwt/private.pem -out config/jwt/public.pem
- Start Symfony Server:
#Symfony CLI
symfony server:start
For more details on setting up Symfony, please refer to the official Symfony documentation
This project has benefited from ideas and code from the following projects and resources:
- php-ddd-example: Example of a PHP application using Domain-Driven Design (DDD) and Command Query Responsibility Segregation (CQRS) principles keeping the code as simple as possible (CodelyTV).
- modular-monolith-example: Modular Monolith Example (Codenip).