Common instructions to pull and setup a Symfony/MySQL project
The required PHP version and extensions are specified in the composer.json file.
To install PHP 8.3 and the necessary extensions:
-
For Linux:
- Add the repository for PHP 8.3:
sudo add-apt-repository ppa:ondrej/php sudo apt update
- Install PHP 8.3 with extensions:
sudo apt install php8.3 php8.3-cli php8.3-{bz2,curl,mbstring,intl} sudo apt install php8.3-fpm sudo apt-get install -y php8.3-common php8.3-mysql php8.3-zip php8.3-gd php8.3-mbstring php8.3-curl php8.3-xml php8.3-bcmath php8.3-imagick php8.3-fileinfo php8.3-iconv pecl install imagick fileinfo iconv
-
For macOS:
brew tap shivammathur/php brew install [email protected] brew install imagemagick
php -r "copy('https://getcomposer.org/installer', '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');"
sudo mv composer.phar /usr/local/bin/composer
-
For macOS:
brew install symfony-cli/tap/symfony-cli
-
For Linux:
wget https://get.symfony.com/cli/installer -O - | bash sudo mv ~/.symfony5/bin/symfony /usr/local/bin/symfony
-
For Linux:
sudo apt install mysql-server sudo mysql_secure_installation
-
For macOS:
brew install mysql brew services start mysql
Note: Before copying the keys, create the oauth folder manually:
mkdir -p ./var/oauth
cp ./tests/keys/* ./var/oauth
mysql
CREATE USER '{db_user}'@'localhost' IDENTIFIED BY '{db_pwd}';
CREATE DATABASE {db_name};
GRANT ALL PRIVILEGES ON {db_name} . * TO '{db_user}'@'localhost';
symfony console doctrine:migrations:migrate
-
For macOS:
brew install node
-
For Linux:
sudo apt install nodejs npm
-
For better compatibility with the actual node version on our servers, it is possible to use nvm. All you have to do is to install nvm and run
nvm use
On project's root directory
For both systems, install Yarn:
npm i -g yarn
composer install
yarn
You can either:
- Write a custom command such as this one AddUserCommand.php
- Or create it straight into the database Generating a Password for the Admin User
symfony server:ca:install
mysql
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
You can deploy to almost any server, any OS, on any web server, on an IAAS or a PAAS infrastructure, on a raw VM or on a dockerized infrastructure. The easiest way is, according to me, to use Symfony Cloud (Platform.sh): Symfony Cloud.
For more information about the deployment of a Symfony Application and web server configuration, please follow the official Symfony documentation: