Skip to content

Symfony 5: The Fast Track book and installing a local PHP version that works!

Having backed Fabien Potencier's "Symfony 5: The Fast Track" book on Kickstarter, I received the book a few weeks ago, and had a chance over the weekend to start reading it.

As a Macbook/OSX user, his recommended environment includes a current locally installed version of PHP with a number of php extension libraries. You also need installation of the php standard composer tool, as well as docker. As I have a Macbook running OSX Mojave, I had to take a number of steps to be able to get started following the book and getting a working installation of the guestbook project using the book's recipe. Here's what I did:

Get the Symfony CLI tool!

Installation instructions and logging into SymfonyCloud are documented. You will want to make a SymfonyCloud (formerly Sensio) account if you didn't already have one.

The symfony cli tool represents the evolution of the original symfony “php console” command, but it's more like an orchestration tool in that it orchestrates git, composer, docker and yarn. The book was written assuming you will use the symfony tool so you won't get far without it.

Local PHP
There are a variety of different ways to get a local updated PHP version, but after trying a few options and running into numerous problems, I settled on Macports. I don't cover that here, but you need to install macports to follow this howto.

With macports installed, you are now ready to install php7.3:

sudo port install php73

Now select this version to be current.

sudo port select php php73

After opening a new terminal window, and running “php -v”:

[david@davids-MacBook-Pro-5:~]$ php -v
PHP 7.3.13 (cli) (built: Dec 21 2019 21:18:35) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.13, Copyright (c) 1998-2018 Zend Technologies

First attempt at installing the book code with the symfony cli
Following the instructions in the book, you'll use the symfony cli:

symfony new --version=5.0-1 --book guestbook

It starts by doing a dependency check on the required modules, and you will likely see output like this:

dependency check issues

Adding the required PHP extensions and other packages
Note that I've listed these as individual macport installs, but you can combine them into one by listing all the packages after 'sudo port install' ie. sudo port install php73-gd php73-intl ... etc.

sudo port install php73-gd 
sudo port install php73-intl 
sudo port install php73-openssl
sudo port install php73-xsl
sudo port install php73-postgresql
sudo port install php73-amqp
sudo port install php73-sodium

This list will satisfy the listed dependencies, however to get a full working install, there are additional extensions required for the composer post install scripts, curl and several other packages are needed:

sudo port install php73-curl
sudo port install php73-iconv
sudo port install php73-mbstring
sudo port install php73-redis
sudo port install yarn

If you list all the installed macport packages you should see this list along with any other packages you might have installed previously, if you already had been using macports:

[david@davids-MacBook-Pro-5:~]$ port installed requested
The following ports are currently installed:
  php73 @7.3.13_0+libedit (active)
  php73-amqp @1.9.4_0 (active)
  php73-curl @7.3.13_0 (active)
  php73-gd @7.3.13_0 (active)
  php73-iconv @7.3.13_0 (active)
  php73-intl @7.3.13_0 (active)
  php73-mbstring @7.3.13_0 (active)
  php73-openssl @7.3.13_0 (active)
  php73-postgresql @7.3.13_0+postgresql12 (active)
  php73-redis @5.1.1_0 (active)
  php73-sodium @7.3.13_0 (active)
  php73-xsl @7.3.13_0 (active)
  yarn @1.19.1_0 (active)

If you had some false starts or incremental installs, you can 'rm -rf guestbook' and re-run the symfony new

[david@davids-MacBook-Pro-5:~]$ symfony new --version=5.0-1 --book guestbook
Checking Book Requirements

[OK] Git installed
[OK] PHP installed version 7.3.13 (/opt/local/bin/php73)
[OK] PHP extension "json" installed
[OK] PHP extension "session" installed
[OK] PHP extension "ctype" installed
[OK] PHP extension "tokenizer" installed
[OK] PHP extension "xml" installed
[OK] PHP extension "intl" installed
[OK] PHP extension "pdo_pgsql" installed
[OK] PHP extension "xsl" installed
[OK] PHP extension "amqp" installed
[OK] PHP extension "gd" installed
[OK] PHP extension "openssl" installed
[OK] PHP extension "sodium" installed
[OK] Composer installed
[OK] Docker installed
[OK] Docker Compose installed

Cloning the Repository

Cloning into '/Users/david/guestbook'...
remote: Enumerating objects: 1170, done.
remote: Counting objects: 100% (1170/1170), done.
remote: Compressing objects: 100% (573/573), done.
remote: Total 1170 (delta 557), reused 1170 (delta 557), pack-reused 0
Receiving objects: 100% (1170/1170), 4.05 MiB | 2.21 MiB/s, done.
Resolving deltas: 100% (557/557), done.

Getting Ready for the Last Step of the Book

[GIT] Check for not yet committed changes: [ OK ]
[GIT] Check Git un-tracked files: [ OK ]

[GIT] Removing Git ignored files (vendor, cache, ...): [ OK ]
[GIT] Resetting Git staged files: [ OK ]
[GIT] Removing un-tracked Git files: [ OK ]
[WEB] Adding .env.local: [ OK ]
[WEB] Stopping Docker Containers: [ OK ]
[WEB] Stopping the Local Web Server: [ OK ]
[WEB] Stopping the SymfonyCloud tunnel: [ OK ]
[GIT] Checking out the step: [ OK ]
[SPA] Stopping the Local Web Server: [ OK ]
[WEB] Installing Composer dependencies (might take some time): [ OK ]
[WEB] Installing PHPUnit (might take some time): [ OK ]
[WEB] Adding .env.local: [ OK ]
[WEB] Starting Docker Compose: [ OK ]
[WEB] Waiting for the Containers to be ready: [ OK ]
[WEB] Migrating the database: [ OK ]
[WEB] Inserting Fixtures: [ OK ]
[WEB] Installing Node dependencies (might take some time): [ OK ]
[WEB] Building CSS and JS assets: [ OK ]
[WEB] Starting the Local Web Server: [ OK ]
[WEB] Starting Message Consumer: [ OK ]
[SPA] Installing Node dependencies (might take some time): [ OK ]
[SPA] Building CSS and JS assets: [ OK ]
[SPA] Starting the Local Web Server: [ OK ]
 [OK] All done!

If everything worked as it should, when you open your browser and enter localhost:8000 as the url you should see a working guestbook page:

Working symfony guestbook page


No Trackbacks


Display comments as Linear | Threaded

Neculiti Ivan on :

*The exact answer

_ _ _ _ _ _ _ _ _ _ _ _ _ _
Neculiti Ivan github fnf

Add Comment

Pavatar, Gravatar, Favatar, MyBlogLog, Pavatar author images supported.
BBCode format allowed
E-Mail addresses will not be displayed and will only be used for E-Mail notifications.
Form options