Professional Documents
Culture Documents
----------------------------------------------------------
----------------------------------------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
----------------------------------------------------------------
***************************************** Symfony
****************************************
Structure de symfony
1- what's the main directory (the directory to be copied on the web server for
deployment)
The web root of a Symfony2 app is the 'web' directory, but when you push to
production the entire symfony2 project should be pushed not just the web root.
web/
app/
A l'int�rieur du bundle
Dans la racine du projet
The assets should be placed in the bundles folder they're related to. This folder
is named "public".
-----------------------------------------------------------------------------------
-------------------------------------------------
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /app.php [QSA,L]
using /app.php puts me into production mode and using /app_dev.php would put me in
development mode.
When Symfony denies the user access, the user sees an error screen and receives a
403 HTTP status code
-----------------------------------------------------------------------------------
-------------------------------------------------
In Symfony, the most basic way to secure part of your application is to secure an
entire URL pattern. Is this true/false?
True
-----------------------------------------------------------------------------------
-------------------------------------------------
The Kernel class implements the logic to load the bundles from ______
container.yaml
bundles.php
parameters.yml
config.php
One file per bundle and bundles.php are the two core concepts that enables Symfony
to automatically manage your bundles and their configurations.
-----------------------------------------------------------------------------------
-------------------------------------------------
var/cache/ should now only be used to store long term cached contents like compiled
container files, compiled translations, or Doctrine proxies. No temporary files.
Basically, anything stored under var/cache should have a warmup class able to
generate the cache files. Files that should never be updated after deployment to
allow for read-only filesystems.
-----------------------------------------------------------------------------------
-------------------------------------------------
-----------------------------------------------------------------------------------
-------------------------------------------------
http://fabien.potencier.org/symfony4-directory-structure.html
-----------------------------------------------------------------------------------
-------------------------------------------------
-----------------------------------------------------------------------------------
-------------------------------------------------
Quelle(s) commande(s) utils�e(s) pour ex�cuter les test phpUnit ?
$ phpunit.php
$ phar.php
$ phpunit -c app/phpunit.xml
$ phpunit
phpunit can be run from the project root without having to explicitly specify the
path of the configuration file.
# Symfony2
phpunit -c app/phpunit.xml
-----------------------------------------------------------------------------------
-------------------------------------------------
-----------------------------------------------------------------------------------
-------------------------------------------------
Les fichiers logs sont stocker dans quelle r�pertoir?
/public/log/
/app/log/
/var/log/
/etc/log/
-----------------------------------------------------------------------------------
-------------------------------------------------
==> See the difference between composer install and composer require?
https://getcomposer.org/doc/01-basic-usage.md
-------------------------------------------------------------------------
When Composer has finished installing, it writes all of the packages and the exact
versions of them that it downloaded to _____?
composer.json
composer.phar
composer.lock
composer
When Composer has finished installing, it writes all of the packages and the exact
versions of them that it downloaded to the composer.lock file, locking the project
to those specific versions. You should commit the composer.lock file to your
project repo so that all people working on the project are locked to the same
versions of dependencies
-----------------------------------------------------------------------------------
-------------------------------------------------
Le ficher composer.json se trouve dans _____?
/var
La racine de votre projet XXXXXX
Les deux a et b
Aucune de ces reponses
-----------------------------------------------------------------------------------
----------------------------
Composer simply resolves all dependencies listed in your composer.json file and
downloads the latest version of their files into the vendor directory in your
project. (The vendor directory is the conventional location for all third-party
code in a project).
-----------------------------------------------------------------------------------
----------------------------
A Composer repository is basically a package source: a place where you can get
packages from. Packagist aims to be the central repository that everybody uses.
This means that you can automatically require any package that is available there,
without further specifying where Composer should look for the package.
-----------------------------------------------------------------------------------
----------------------------
-----------------------------------------------------------------------------------
----------------------------
$session = $request->getSession();
{{ app.session.getRequest('foo', 'bar'); }}
{{ app.getSession('foo', 'bar'); }}
{{ app.session.get('foo', 'bar'); }} XXXXX
Aucune de ces reponses
-----------------------------------------------------------------------------------
----------------------------
$session = $request->getSession();
$request->getSession('foo');
$session->get('foo'); XXXXXX
Request::getSession('foo');
Aucune de ces reponses
-----------------------------------------------------------------------------------
----------------------------
Soulution :
framework:
session:
cookie_lifetime: 43200 #time in seconds
-----------------------------------------------------------------------------------
----------------------------
Quelle directive est utilis� pour restreindre l'acc�es � /admin dans le fichier
"security.yaml"?
allow_if:
access_control: XXXXXXX
deny_access:
is_granted:
# config/packages/security.yaml
security:
# ...
access_control:
# require ROLE_ADMIN for /admin*
- { path: ^/admin, roles: ROLE_ADMIN }
-----------------------------------------------------------------------------------
----------------------------
If you want to check if the current access inside a template, use the built-in
is_granted() helper function:
-----------------------------------------------------------------------------------
----------------------------
Quelle annotation utilis� pour restrict access prevent access to a specific actions
on controller ?
(A) @Security
(B) @IsAuthenticated
(C) @IsGranted
les deux A et C sont vrais. XXXXXXXXX
Aucune de ces r�ponses n'est vraie.
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
-----------------------------------------------------------------------------------
----------------------------
/vendor/autoload.php
/src/Kernel.php XXXXXXX
/config/services.yaml
/app/config/parameters.yml
/app/config/config.yml
-----------------------------------------------------------------------------------
----------------------------
(A)
// BAD - $user->getRoles() will not know about the role hierarchy
$hasAccess = in_array('ROLE_ADMIN', $user->getRoles());
(B)
// GOOD - use of the normal security methods
$hasAccess = $this->isGranted('ROLE_ADMIN'); XXXXXXX
(C)
$hasAccess = $this->container->isGranted('ROLE_ADMIN');
(D)
$hasAccess = $user->hasRole('ROLE_ADMIN')
-----------------------------------------------------------------------------------
----------------------------
access_control:
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/, roles: ROLE_ADMIN }
-----------------------------------------------------------------------------------
----------------------------
-----------------------------------------------------------------------------------
----------------------------
Dans Symfony3 le r�pertoir app/cache et app/logs ont �t� d�plac�s vers ______
var/dev/
var/ XXXXXXX
/var/www
Aucune de ces r�ponses n'est vraie.
-----------------------------------------------------------------------------------
----------------------------
Dans Symfony3, Quelle commande utiliser pour vider le cache dans l'environement de
production?
$ php app/console cache:warmup --env=prod
$ php app/console cache:clear --env=prod
$ php bin/console cache:clear --env=prod XXXXXXXXX
$ php app/console cache:clear --environment=prod
-----------------------------------------------------------------------------------
----------------------------
Quelle commande pour valider le mapping entre les entit�s et les tables ?
-----------------------------------------------------------------------------------
----------------------------
Exemple:
-----------------------------------------------------------------------------------
----------------------------
-----------------------------------------------------------------------------------
----------------------------
# src/Acme/TaskBundle/Resources/config/services.yml
services:
acme_demo.form.type.product:
class: Acme\ProductBundle\Form\Type\ProductType
tags:
- { name: form.type, alias: product }
define your form class as a service allow you to re-use the form in several places.
-----------------------------------------------------------------------------------
----------------------------
-----------------------------------------------------------------------------------
----------------------------
D'abord, nous enregistrons le service en tant que "Doctrine Event Listeners" dans
le fichier "app/config.yml":
services:
my.listener:
class: Vendor\AcmeBundle\ProductClass
tags:
- { name: doctrine.event_listener, event: ..................,
method: .................... }
Pr�ciser l'evenement sur lequel nous devons �couter, et quelle m�thode sera
utiliser lorsque l'�v�nement est d�clench�?
services:
foo.listener:
class: Vendor\FooBundle\BarClass
tags:
- { name: doctrine.event_listener, event: postPersist, method:
onPostPersist }
-----------------------------------------------------------------------------------
----------------------------
-----------------------------------------------------------------------------------
----------------------------
-----------------------------------------------------------------------------------
----------------------------
-----------------------------------------------------------------------------------
----------------------------
-----------------------------------------------------------------------------------
----------------------------
Comment d�truire l'�lement 'blog.pages_count' dans le cache de Symfony?
$ php app/console doctrine:cache:clear blog.pages_count
$cache->delete('blog.pages_count'); XXXXXX
$cache->drop('blog.pages_count);
$cache->set('blog.pages_count', null);
-----------------------------------------------------------------------------------
----------------------------