Deployment Symfony

From Journey

This step needs to be done deploying from Github, something I am currently working on.

At this time, this next step needs an SSH connection to the cPanel server.

Deploy12.png

Let's go into the deployment directory.

gospelnet@gospel.net.nz [~]# cd deploy.gospel.net.nz/
gospelnet@gospel.net.nz [~/deploy.gospel.net.nz]#

Install Composer

We are working with a Symfony 4.2 installation. We are heading towards Symfony 4.4 and also Symfony 5.1, but all this takes time.

A small note to start with is that we are running PHP 7.4 on this installation. With allow_url_fopen = On

gospelnet@gospel.net.nz [~/deploy.gospel.net.nz]#  php -v
PHP 7.4.10 (cgi-fcgi) (built: Sep 29 2020 18:56:48)
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
   with Zend OPcache v7.4.10, Copyright (c), by Zend Technologies

Go to https://getcomposer.org/download/ for the first part of the installation.

This changes from time to time so it is best to get the instructions from there, but this is what I did October 2020.

/opt/cpanel/ea-php74/root/usr/bin/php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
/opt/cpanel/ea-php74/root/usr/bin/php -r "if (hash_file('sha384', 'composer-setup.php') === '795f976fe0ebd8b75f26a6dd68f78fd3453ce79f32ecb33e7fd087d39bfeb978342fb73ac986cd4f54edd0dc902601dc') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
Installer verified
/opt/cpanel/ea-php74/root/usr/bin/php composer-setup.php
All settings correct for using Composer
Downloading...

Composer (version 1.10.13) successfully installed to: /home/gospelnet/deploy.gospel.net.nz/composer.phar
Use it: php composer.phar
/opt/cpanel/ea-php74/root/usr/bin/php -r "unlink('composer-setup.php');"

Setup Symfony 4.2

At the moment I can only get 4.2 running from an existing copy, I really need to upgrade to 4.4.

  1. Copied across from a working website
  2. Changed Ownership
  3. Changed .env to the correct database.
  4. Checked access
  5. Run as website user: APP_ENV=prod APP_DEBUG=0 php bin/console -vvv cache:clear
  6. Check Error Had an Out Of Memory, so adjusted the local php.ini

Getting un successfully.

Setup Symfony 4.4

Note, we are working on a cPanel Server.

Having setup Composer, next

/opt/cpanel/ea-php72/root/usr/bin/php ./composer.phar create-project symfony/website-skeleton:^4.4 my_project_name

It is useful to note that I got out of memory errors. And even though I increased the local php.imi file to a 512M, the error persisted until I increted the main php.imi file to 128M.

Afterward, I reduced the main php.ini file back down to 64M

4.4 Results

Next, we want to move all these files into the root of this website.

mv my_project_name/{*,.*} ./ 
rm -rf my_project_name

The Directory & File structure should look something like this.

./   bin/      composer.json  composer.phar*  .env       .gitignore  migrations/  php.ini~          public/  symfony.lock  tests/         var/     .well-known/ ../  cgi-bin/  composer.lock  config/         .env.test  .htaccess   php.ini      phpunit.xml.dist  src/     templates/    translations/  vendor/

You should be able to go to your URL and see a working Symfony.

Deploy14.png

All is good.

If you get this

Composer Packages

We need to install the following Composer Packagers.

   "require": {
       "php": "^7.4.0",
       "ext-ctype": "*",
       "ext-iconv": "*",
       "dompdf/dompdf": "^0.8.5",
       "easycorp/easyadmin-bundle": "^2.0",
       "friendsofsymfony/ckeditor-bundle": "^2.0",
       "friendsofsymfony/user-bundle": "^2.1",
       "intervention/image": "^2.4",
       "league/csv": "^9.1",
       "sensio/framework-extra-bundle": "^5.2",
       "suncat/mobile-detect-bundle": "^1.1",
       "symfony/apache-pack": "^1.0",
       "symfony/asset": "4.2.*",
       "symfony/console": "4.2.*",
       "symfony/dotenv": "4.2.*",
       "symfony/expression-language": "4.2.*",
       "symfony/flex": "^1.1",
       "symfony/form": "4.2.*",
       "symfony/framework-bundle": "4.2.*",
       "symfony/messenger": "4.2.*",
       "symfony/monolog-bundle": "^3.3",
       "symfony/orm-pack": "^1.0",
       "symfony/process": "4.2.*",
       "symfony/routing": "4.2.*",
       "symfony/security-bundle": "4.2.*",
       "symfony/serializer-pack": "^1.0",
       "symfony/swiftmailer-bundle": "^3.2",
       "symfony/translation": "4.2.*",
       "symfony/twig-bundle": "4.2.*",
       "symfony/validator": "4.2.*",
       "symfony/web-link": "4.2.*",
       "symfony/webpack-encore-bundle": "^1.0",
       "symfony/yaml": "4.2.*",
       "tattali/calendar-bundle": "^1.1",
       "vich/uploader-bundle": "^1.8"
   },

At this point, we have installed

   "require": {
       "php": ">=7.4.0",
       "ext-ctype": "*",
       "ext-iconv": "*",
       "composer/package-versions-deprecated": "^1.11",
       "doctrine/annotations": "^1.0",
       "doctrine/doctrine-bundle": "^2.1",
       "doctrine/doctrine-migrations-bundle": "^3.0",
       "doctrine/orm": "^2.7",
       "phpdocumentor/reflection-docblock": "^5.2",
       "sensio/framework-extra-bundle": "^5.1",
       "symfony/asset": "4.4.*",
       "symfony/console": "4.4.*",
       "symfony/dotenv": "4.4.*",
       "symfony/expression-language": "4.4.*",
       "symfony/flex": "^1.3.1",
       "symfony/form": "4.4.*",
       "symfony/framework-bundle": "4.4.*",
       "symfony/http-client": "4.4.*",
       "symfony/intl": "4.4.*",
       "symfony/mailer": "4.4.*",
       "symfony/monolog-bundle": "^3.1",
       "symfony/process": "4.4.*",
       "symfony/property-access": "4.4.*",
       "symfony/property-info": "4.4.*",
       "symfony/security-bundle": "4.4.*",
       "symfony/serializer": "4.4.*",
       "symfony/translation": "4.4.*",
       "symfony/twig-bundle": "^4.4",
       "symfony/validator": "4.4.*",
       "symfony/web-link": "4.4.*",
       "symfony/yaml": "4.4.*",
       "twig/extra-bundle": "^2.12|^3.0",
       "twig/twig": "^2.12|^3.0"
   },

These are things we are currently adding

/opt/cpanel/ea-php74/root/usr/bin/php ./composer.phar require easycorp/easyadmin-bundle
/opt/cpanel/ea-php74/root/usr/bin/php ./composer.phar require friendsofsymfony/ckeditor-bundle

if you get asked to run a recipe.... DO!

Do you want to execute this recipe?
   [y] Yes
   [n] No
   [a] Yes for all packages, only for the current installation session
   [p] Yes permanently, never ask again for this project
   (defaults to n): y

if you have symfony/apache-pack installed, uninstall it.

/opt/cpanel/ea-php74/root/usr/bin/php ./composer.phar remove symfony/apache-pack

Now run

/opt/cpanel/ea-php74/root/usr/bin/php ./composer.phar require doctrine

When I first ran this, it kept saying that my PHP version was 7.2 when it was 7.4 once I relogged in as the actual user and not promoting myself across users, this command worked.

/opt/cpanel/ea-php74/root/usr/bin/php ./composer.phar require friendsofsymfony/user-bundle

Setup Symfony 5.1.99

Symfony 5.1.99