Skip to content

nsiksnys/arbell-php-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

arbell-php-test

Technical test done in May/June 2025

Created with

Also used

Branches

This project contains two main branches

  • the web branch, which contains a site for basic User CRUD operations.
  • the rest-api branch, which contains a REST API for basic User CRUD operations.

Composer packages

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.

Some technical details

  • 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 role variable, that follows the ROLE_[NAME] convention used in Symfony. These are created using migrations. For more information about this, go to the Test data section.
  • In the web branch, role names are managed through the RoleEnum enum 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.

User permissions

  • Only authenticated users can access the CRUD.
  • Only users with admin profile (ROLE_ADMIN) can send DELETE requests.

Database entity-relation diagram

Diagram generated by phpMyAdmin Note: doctrine_migration_versions is an internal table used to keep track of executed migrations.

Environment variables

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_ENV to point which environment we are using. By default is set to dev.
  • DATABASE_URL to connect with the MySql/MariaDB database. The value for MariaDB versions from 10.11.2 is mysql://[USER]:[PASSWORD]@[DB_URL]:[DB_PORT]/[DB_NAME]?serverVersion=10.11.2-MariaDB&charset=utf8mb4 where
    • USER is a valid database engine user, with at least reading and writing permissions
    • PASSWORD is the user password
    • DB_URL is the url used by the database engine. For local environments, the default is localhost
    • DB_PORT is the port used by the database engine for listening. For local environment, the default is 3306
    • DB_NAME is 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-bundle package used in the rest-api branch
    • JWT_SECRET_KEY defines the location of the secret key. Defaults to %kernel.project_dir%/config/jwt/private.pem.
    • JWT_PUBLIC_KEY defines the location of the public key. Defaults to %kernel.project_dir%/config/jwt/public.pem.
    • JWT_PASSPHRASE is 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.

Test data

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.

Running locally

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.

Screenshots

Web

Home page

Without being logged in

Without being logged in

Logged in

Logged in

Login

Login

List

User index

Creation

New user form Message after creating user

Details

User details

Edit

Edit user form Change password form Message after updating user

Deletion

Delete user modal Message after deleting user

Access denied

User list access denied

User deletion denied

User deletion denied

Mobile (iPad 810x1080)

Mobile (iPad 810x1080)

Examples (done with Imsomnia)

Requests available at insomnia_api_requests.yml

Login (get authorization token)

POST auth

Set authorization token

Auth Bearer token

Get all profiles

GET all profiles

Get all users

GET all users

Creation new user (with Faker)

POST user

Get one user in particular

GET user

Edit a specific user

PATCH user

Edit a specific user - email validaton error

PATCH user validation error

Delete a specific user

DELETE user

Authorization

Delete user - access denied for user with ROLE_USER profile

DELETE user 403

Get all users - access denied for unauthenticated user

GET users 401

About

Technical test done in May/June 2025

Topics

Resources

License

Stars

Watchers

Forks

Contributors