Technical test done in May/June 2025
Created with
Also used
- MariaDB
- Symfony Profiler
- LexikJWTAuthenticationBundle for JWT (JSON Web Token) authentication
This project contains two main branches
- the
webbranch, which contains a site for basic User CRUD operations. - the
rest-apibranch, which contains a REST API for basic User CRUD operations.
Run composer install to install all required packages
In the rest-api branch run php bin/console lexik:jwt:generate-keypair to generate the public and private keys used for signing JWT tokens.
- The project is done in Symfony to take advantage of their roles and permissions capabilities.
- Permissions are managed through the Profile entity. Each of them contains the
rolevariable, that follows theROLE_[NAME]convention used in Symfony. These are created using migrations. For more information about this, go to theTest datasection. - In the
webbranch, role names are managed through theRoleEnumenum to avoid any confusion. - The database is MariaDB, the open source version of MySql. It is possible to switch to MySql, just update the url as explained later in this document.
- Only authenticated users can access the CRUD.
- Only users with admin profile (
ROLE_ADMIN) can send DELETE requests.
Note: doctrine_migration_versions is an internal table used to keep track of executed migrations.
All envirnoment variables are managed using a .env file.
This proyect comes with an example .env. Symfony allows .env.[ENVIRONMENT_NAME] files, to store variables of a specific environment.
In this case we need to set up before running the project for the first time.
APP_ENVto point which environment we are using. By default is set todev.DATABASE_URLto connect with the MySql/MariaDB database. The value for MariaDB versions from 10.11.2 ismysql://[USER]:[PASSWORD]@[DB_URL]:[DB_PORT]/[DB_NAME]?serverVersion=10.11.2-MariaDB&charset=utf8mb4whereUSERis a valid database engine user, with at least reading and writing permissionsPASSWORDis the user passwordDB_URLis the url used by the database engine. For local environments, the default islocalhostDB_PORTis the port used by the database engine for listening. For local environment, the default is3306DB_NAMEis the database name
For MySql databases, use DATABASE_URL="mysql://[USER]:[PASSWORD]@[DB_URL]:[DB_PORT]/[DB_NAME].
For older MariaDB versions or other databases, go to Databases and the Doctrine ORM in the official Symfony documentation.
- The following keys belong to the
lexik/jwt-authentication-bundlepackage used in therest-apibranchJWT_SECRET_KEYdefines the location of the secret key. Defaults to%kernel.project_dir%/config/jwt/private.pem.JWT_PUBLIC_KEYdefines the location of the public key. Defaults to%kernel.project_dir%/config/jwt/public.pem.JWT_PASSPHRASEis required for token creation. This variable should be added automatically after generating the keys.
For more information about this package, go to its official GitHub repo.
Run php bin/console doctrine:database:create to create an empty database. Note that this command will fail if the database user does not have creating permissions.
Run php bin/console make:migrations:migrate to create all the database tables and fill them with test data.
Test data consists of the two profiles, one with role ROLE_ADMIN and other with role ROLE_USER, and one user, admin@example.com with admin capabilities and password test123.
For local development, we can use the Symfony binary to run the local server.
Once the binary is installed, run php bin/console asset-map:compile --no-debug to compile all assets, followed by symfony server:start. If this last command does not work, check where the symfony binary is located. For Linux systems the default location is $HOME/.symfony/bin.
By default, the server is available at http://localhost:8000.
Requests available at insomnia_api_requests.yml

























