CRUD avec Symfony 3.
1/ Répertoire de travail.
[~] ➔ mkdir -p GITHUBAPI [~] ➔ cd GITHUBAPI/ [~/GITHUBAPI] ➔
2/ Initilisation du projet Symfony.
[~/GITHUBAPI] ➔ symfony new gitgame1 ... Downloading Symfony... ... Preparing project... ... [~/GITHUBAPI] ➔
3/ Lancement du serveur.
[~/GITHUBAPI] ➔ cd gitgame1/ [~/GITHUBAPI/gitgame1] ➔ php bin/console server:start [OK] Server listening on http://127.0.0.1:8000 [~/GITHUBAPI/gitgame1] ➔
4/ Test.
5/ Téléchargement de ‘composer‘.
[~/GITHUBAPI/gitgame1] ➔ curl -s http://getcomposer.org/installer | php All settings correct for using Composer Downloading... Composer (version 1.4.2) successfully installed to: /home/util01/GITHUBAPI/gitgame1/composer.phar Use it: php composer.phar [~/GITHUBAPI/gitgame1] ➔
6/ Installation du bundle ‘crud-generator-bundle‘.
[~/GITHUBAPI/gitgame1] ➔ php composer.phar require petkopara/crud-generator-bundle Using version ^3.0 for petkopara/crud-generator-bundle ... > Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installRequirementsFile > Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::prepareDeploymentTarget [~/GITHUBAPI/gitgame1] ➔
7/ Action du bundle.
Ouvrir :
app/AppKernel.php
Chercher :
new AppBundle\AppBundle(),
Ajouter après :
new Lexik\Bundle\FormFilterBundle\LexikFormFilterBundle(), new Petkopara\MultiSearchBundle\PetkoparaMultiSearchBundle(), new Petkopara\CrudGeneratorBundle\PetkoparaCrudGeneratorBundle(),
8/ Configuration de Twig.
Ouvrir :
app/config/config.yml
Chercher :
twig: debug: '%kernel.debug%' strict_variables: '%kernel.debug%'
Ajouter après :
form_themes: - 'bootstrap_3_layout.html.twig'
9/ Configuration du serveur de base de données.
Ouvrir :
app/config/parameters.yml
Chercher :
database_name: symfony database_user: root database_password: null
Remplacer par :
database_name: gitgame database_user: root database_password: mot2passe
10/ Génération de bundle.
[~/GITHUBAPI/gitgame1] ➔ php bin/console generate:bundle --namespace=GitteamBundle ... What format do you want to use for your generated configuration? Configuration format (annotation, yml, xml, php) [annotation]: yml ... Everything is OK! Now get to work :). [~/GITHUBAPI/gitgame1] ➔
11/ Installation des assets.
[~/GITHUBAPI/gitgame1] ➔ php bin/console assets:install --symlink ... [OK] All assets were successfully installed. [~/GITHUBAPI/gitgame1] ➔
12/ Création de la base de données.
Avec PhpMyAdmin : http://localhost/phpmyadmin
Création de la base de données : gitgame
13/ Génération des entitées.
[~/GITHUBAPI/gitgame1] ➔ php bin/console doctrine:generate:entity ... First, you need to give the entity name you want to generate. You must use the shortcut notation like AcmeBlogBundle:Post. The Entity shortcut name: GitteamBundle:Team ... New field name (pressto stop adding fields): Name Field length [255]: 200 ... New field name (press to stop adding fields): Description Field length [255]: 200 ... Everything is OK! Now get to work :). [~/GITHUBAPI/gitgame1] ➔
14/ Mise-à-jour du schéma de la base de données.
[~/GITHUBAPI/gitgame1] ➔ php bin/console doctrine:schema:update --force Updating database schema... Database schema updated successfully! "1" query was executed [~/GITHUBAPI/gitgame1] ➔
15/ Génération CRUD.
[~/GITHUBAPI/gitgame1] ➔ php bin/console petkopara:generate:crud --overwrite ... First, give the name of the existing entity for which you want to generate a CRUD (use the shortcut notation like AcmeBlogBundle:Post) The Entity shortcut name: GitteamBundle:Team By default, the generator creates all actions: list and show, new, update, and delete. You can also skip it and to generate only "list and show" actions: Do you want to skip generating of the "write" actions [no]? ... Everything is OK! Now get to work :). [~/GITHUBAPI/gitgame1] ➔
16/ Test.
17/ Liens.
http://symfony-howtos.blogspot.fr/2016/07/symfony-31-create-database-project-with.html
https://github.com/petkopara/PetkoparaCrudGeneratorBundle
Comments are closed, but trackbacks and pingbacks are open.