2016-10-22 11:53:30 +02:00
# Practice Symfony
2017-09-13 18:45:14 +02:00
* Documentation : < https: // symfony . com / doc / current / index . html >
* Rôle : < https: // forge . evolix . org / projects / ansible-roles / repository / show / php > avec `php_symfony_requirements: True`
[Symfony ](http://symfony.com/ ) est le framework PHP le plus populaire.
2016-10-22 11:53:30 +02:00
## Prérequis
2017-09-13 18:45:14 +02:00
< http: / / symfony . com / doc / current / reference / requirements . html >
2016-10-22 11:53:30 +02:00
### Apache
2017-09-13 18:45:14 +02:00
< http: / / symfony . com / doc / current / setup / web_server_configuration . html >
2017-09-13 18:47:31 +02:00
Les applications Symfony contiennent souvent des fichiers `.htaccess` avec des directives `DirectoryIndex` , `Options -MultiViews` , `Rewrite*` , `Deny` .
2017-09-13 18:45:14 +02:00
Il est donc plutôt conseillé d'utiliser [Apache ](HowtoApache ) en général.
2016-10-22 11:53:30 +02:00
La configuration Apache du VirtualHost doit donc contenir au minimum :
~~~{.apache}
AllowOverride Limit FileInfo Indexes Options=All,MultiViews
~~~
### PHP
2017-09-13 18:45:14 +02:00
Le module JSON doit être installé :
2016-10-22 11:53:30 +02:00
2017-09-13 18:45:14 +02:00
~~~
# apt install php7.0-json
~~~
> *Note* : Pour Debian 8
>
> ~~~
> # aptitude install php5-json
> ~~~
Et il faut préciser le paramètre `date.timezone` dans les fichiers de configuration PHP.
Par exemple pour la France :
~~~
# grep -r date.timezone /etc/php/7.0/*/conf.d/zzz-evolinux-custom.ini
2016-10-22 11:53:30 +02:00
2017-09-13 18:45:14 +02:00
/etc/php/7.0/apache2/conf.d/zzz-evolinux-custom.ini: date.timezone = "Europe/Paris"
/etc/php/7.0/cli/conf.d/zzz-evolinux-custom.ini: date.timezone = "Europe/Paris"
/etc/php/7.0/fpm/conf.d/zzz-evolinux-custom.ini: date.timezone = "Europe/Paris"
~~~
2016-10-22 11:53:30 +02:00
2017-12-08 11:48:52 +01:00
Il faut aussi s'assurer que des fonctions comme `putenv` ne sont pas bloquées
2016-10-22 11:53:30 +02:00
2017-09-06 15:46:14 +02:00
## Installation
2016-10-22 11:53:30 +02:00
2017-09-13 18:45:14 +02:00
La méthode conseillée est d'utiliser [Composer ](HowtoPHP#composer ).
Par exemple pour installer Symfony 3.3 :
2016-12-29 15:26:14 +01:00
~~~
2017-09-06 15:46:14 +02:00
$ echo '{"require": {{"symfony/framework-standard-edition": "~3.3"}}' > composer.json
$ composer update
Loading composer repositories with package information
[...]
$ cd vendor/symfony/framework-standard-edition
$ composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
- Installing doctrine/lexer (v1.0.1)
Loading from cache
[...]
~~~
Pour tester la configuration, des tests peuvent être lancés ainsi :
~~~
$ cd vendor/symfony/framework-standard-edition
2016-10-22 11:53:30 +02:00
$ php bin/symfony_requirements
2017-09-06 15:46:54 +02:00
2017-09-06 15:46:14 +02:00
Symfony Requirements Checker
> PHP is using the following php.ini file:
/etc/php/7.0/cli/php.ini
> Checking Symfony requirements:
................................W........
2017-09-06 15:46:54 +02:00
2017-09-06 15:46:14 +02:00
[OK]
Your system is ready to run Symfony projects
[...]
2016-12-29 15:26:14 +01:00
~~~
2017-09-13 18:45:14 +02:00
## Application Symfony
Pour avoir une application de test, on peut utiliser l'application de nos amis d'[Acseo](http://www.acseo.fr/) disponible sur < https: / / github . com / acseo / symfony-perf > :
On applique le < https: / / github . com / acseo / symfony-perf / blob / master / INSTALL . md > :
~~~
$ git clone https://github.com/acseo/symfony-perf.git
$ cd symfony-perf
$ composer install
$ chmod -R g+w var
~~~