Skip to main content

Installation projet Symfony/MySql

1) Setup PHP >= 8.1 and extensions

// For MacOX
brew install php pkg-config imagemagick
pecl install imagick fileinfo iconv
// For Linux (depends on the package manger fo course)
sudo apt update && sudo apt install --no-install-recommends php8.1
sudo apt-get install -y php8.1-cli php8.1-common php8.1-mysql php8.1-zip php8.1-gd php8.1-mbstring php8.1-curl php8.1-xml php8.1-bcmath php8.1-imagick php8.1-fileinfo php8.1-iconv
pecl install imagick fileinfo iconv

2) Install Composer globally

php -r "copy('', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '55ce33d7678c5a611085589f1f3ddf8b3c52d662cd01d4ba75c0ee0459970c2200a51f492d557530c71c15d8dba01eae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"

3) Install Symfony binary

// For MacOX
brew install symfony-cli/tap/symfony-cli
// For Linux
curl -1sLf '' | sudo -E bash
sudo apt install symfony-cli

4) Install MySqL

// For MacOX
brew instal mySql
// For Linux
sudo apt install mysql-server
sudo mysql_secure_installation

5) Copy keys from ./tests/keys to ./var/oauth

 cp ./tests/keys/* ./var/oauth

6) Create a MySql database, user, and grant

CREATE USER '{db_user}'@'localhost' IDENTIFIED BY '{db_pwd}'; CREATE DATABASE {db_name}; GRANT ALL PRIVILEGES ON {db_name} . * TO '{db_user}'@'localhost';

7) Run migrations

symfony console docrine:migrations:migrate

8) Install Node, Npm, Yarn

// For MacOX
brew instal node
// For Linux
sudo apt install nodejs npm
// For both, install Yarn
npm i -g yarn

9) Install Dependencies

composer install

10) Install certificates for local SSL

symfony server:ca:install

11) Setup tests

CREATE DATABASE {test_db_name}; GRANT ALL PRIVILEGES ON {test_db_name} . * TO '{db_user}'@'localhost';
symfony console doctrine:migrations:migrate --env=test
php ./vendor/bin/simple-phpunit tests