Changes between Version 2 and Version 3 of members/GRIP-UQAM/Doctrine_(PHP)
- Timestamp:
- Jan 12, 2017, 7:30:48 PM (9 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
members/GRIP-UQAM/Doctrine_(PHP)
v2 v3 1 1 [[PageOutline]] 2 == [https://packagist.org/packages/doctrine/orm doctrine/orm] == 3 === Doctrine Console === 2 * [WikiPedia:Doctrine_(PHP)] 3 = [https://phppackages.org/p/doctrine/dbal doctrine/dbal] = 4 == Configuration and testing it == 5 = [https://phppackages.org/p/doctrine/orm doctrine/orm] = 6 == Doctrine Console == 4 7 * http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/tools.html 5 8 * https://sonata-project.org/bundles/admin/2-3/doc/getting_started/creating_an_admin.html … … 8 11 $ php bin/console doctrine:generate:entity --entity="AppBundle:BlogPost" --fields="title:string(255) body:text draft:boolean" --no-interaction 9 12 }}} 10 == = Relations ===13 == Relations == 11 14 * //Les relations entre entités avec Doctrine2// [https://openclassrooms.com/courses/developpez-votre-site-web-avec-le-framework-symfony2/les-relations-entre-entites-avec-doctrine2 OpenClassrooms] 12 15 * //Les relations entre entités dans Symfony2 avec Doctrine// [http://www.lafermeduweb.net/tutorial/les-relations-entre-entites-dans-symfony2-avec-doctrine-p97.html lafermeduweb] 13 == = Cascade ===16 == Cascade == 14 17 * doctrine ondelete 15 18 * doctrine one to many cascade … … 17 20 * //Doctrine Cascade Options for OneToMany// [https://stackoverflow.com/questions/7709293/doctrine-cascade-options-for-onetomany stackoverflow] 18 21 * //cascade={“remove”} VS orphanRemoval=true VS ondelete="CASCADE// [https://stackoverflow.com/questions/27472538/cascade-remove-vs-orphanremoval-true-vs-ondelete-cascade stackoverflow] 19 == = Events ===22 == Events == 20 23 * https://openclassrooms.com/courses/developpez-votre-site-web-avec-le-framework-symfony2/les-evenements-et-extensions-doctrine 21 == = Extensions - Behaviors ===24 == Extensions - Behaviors == 22 25 Gedmo are a standard, but Translatable is criticized 23 26 * [https://packagist.org/packages/gedmo/doctrine-extensions gedmo/doctrine-extensions] … … 27 30 * //Gedmo l'extension Doctrine 2 dans Symfony2// 2012 [http://julien.edouard.overblog.com/gedmo-l-extension-doctrine-2-dans-symfony2 overblog] 28 31 * [https://packagist.org/packages/knplabs/doctrine-behaviors knplabs/doctrine-behaviors] 29 === = Compatibility Issues between Extensions ====32 === Compatibility Issues between Extensions === 30 33 * SoftDeleteable - Sortable 31 34 * https://github.com/Atlantic18/DoctrineExtensions/blob/master/doc/softdeleteable.md#extra 32 35 * Sluggable, Translatable and Tree 33 36 * https://github.com/Atlantic18/DoctrineExtensions/blob/master/doc/tree.md#nesting-translatable-and-sluggable-extensions 34 === = Audit, Revision or Loggable ====37 === Audit, Revision or Loggable === 35 38 * Versioning of entities and their associations [https://packagist.org/packages/simplethings/entity-audit-bundle simplethings/entity-audit-bundle] 36 39 * https://sonata-project.org/bundles/doctrine-orm-admin/master/doc/reference/audit.html … … 40 43 * [https://www.youtube.com/watch?v=wxgIHNtEN84 YouTube] 41 44 * Loggable is able to track lifecycle modifications and log them using any third party log system [https://github.com/KnpLabs/DoctrineBehaviors#loggable KNP Labs] 42 === = Blameable ====45 === Blameable === 43 46 * Updates string or reference fields on create, update and even property change with a string or object (e.g. user) [https://github.com/Atlantic18/DoctrineExtensions/blob/master/doc/blameable.md Gedmo] 44 47 * Track creators and updators of a given entity [https://github.com/KnpLabs/DoctrineBehaviors#blameable KNP Labs] 45 === = Filterable ====48 === Filterable === 46 49 * Simple filter result [https://github.com/KnpLabs/DoctrineBehaviors#filterable KNP Labs] 47 === = Geocodable ====50 === Geocodable === 48 51 * Extensions to PostgreSQL platform in order to work with cube and earthdistance extensions [https://github.com/KnpLabs/DoctrineBehaviors#geocodable KNP Labs] 49 === = IpTraceable ====52 === IpTraceable === 50 53 * Inherited from Timestampable, sets IP address instead of timestamp [https://github.com/Atlantic18/DoctrineExtensions/blob/master/doc/ip_traceable.md Gedmo] 51 === = Joinable ====54 === Joinable === 52 55 * KNP Labs 53 === = Loggable (see Audit, Revision) ====56 === Loggable (see Audit, Revision) === 54 57 ==== References ==== 55 58 * Supports linking Entities in Documents and vice versa [https://github.com/Atlantic18/DoctrineExtensions/blob/master/doc/references.md Gedmo] 56 === = ReferenceIntegrity ====59 === ReferenceIntegrity === 57 60 * Constrains ODM MongoDB Document references [https://github.com/Atlantic18/DoctrineExtensions/blob/master/doc/reference_integrity.md Gedmo] 58 === = Revision (see Audit, Loggable) ====59 === = Sluggable ====61 === Revision (see Audit, Loggable) === 62 === Sluggable === 60 63 * Urlizes your specified fields into single unique slug [https://github.com/Atlantic18/DoctrineExtensions/blob/master/doc/sluggable.md Gedmo] 61 64 * Sluggable generates slugs (uniqueness is not guaranteed) for an entity [https://github.com/KnpLabs/DoctrineBehaviors#sluggable KNP Labs] 62 65 * Sluggable, Translatable and Tree (Compatibility issue) 63 66 * https://github.com/Atlantic18/DoctrineExtensions/blob/master/doc/tree.md#nesting-translatable-and-sluggable-extensions 64 === = SoftDeleteable ====67 === SoftDeleteable === 65 68 * Allows to implicitly remove records [https://github.com/Atlantic18/DoctrineExtensions/blob/master/doc/softdeleteable.md Gedmo] [https://github.com/KnpLabs/DoctrineBehaviors#softDeletable KNP Labs] 66 69 * SoftDeleteable - Sortable (Compatibility issue) … … 70 73 * //StofDoctrineExtensionsBundle softdelete - How do I use it?// [https://stackoverflow.com/questions/16670454/stofdoctrineextensionsbundle-softdelete-how-do-i-use-it stackoverflow] 71 74 * //Episode 39 - Utiliser l'extension softdeleteable avec Symfony2// DevAndClick [https://www.youtube.com/watch?v=kBzDiOFaRFY YouTube (fr)] 72 === = Sortable ====75 === Sortable === 73 76 * Makes any document or entity sortable [https://github.com/Atlantic18/DoctrineExtensions/blob/master/doc/sortable.md Gedmo] KNP Labs 74 77 * SoftDeleteable - Sortable (Compatibility issue) 75 78 * https://github.com/Atlantic18/DoctrineExtensions/blob/master/doc/softdeleteable.md#extra 76 === = Timestampable ====79 === Timestampable === 77 80 * Updates date fields on create, update and even property change [https://github.com/Atlantic18/DoctrineExtensions/blob/master/doc/timestampable.md Gedmo] [https://github.com/KnpLabs/DoctrineBehaviors#timestampable KNP Labs] 78 === = Translatable ====81 === Translatable === 79 82 * Gives you a very handy solution for translating records into different languages [https://github.com/Atlantic18/DoctrineExtensions/blob/maste/doc/translatable.md Gedmo] 80 83 * [https://github.com/Atlantic18/DoctrineExtensions/blob/master/doc/translatable.md#example-code-to-use-personal-translations-with-symfony2-sonata-i18n-forms Example code to use Personal Translations with (Symfony2 Sonata) i18n Forms] … … 82 85 * Sluggable, Translatable and Tree (Compatibility issue) 83 86 * https://github.com/Atlantic18/DoctrineExtensions/blob/master/doc/tree.md#nesting-translatable-and-sluggable-extensions 84 === = Translator ====87 === Translator === 85 88 * Explicit way to handle translations [https://github.com/Atlantic18/DoctrineExtensions/blob/master/doc/translatable.md Gedmo] 86 === = Tree ====89 === Tree === 87 90 * This extension automates the tree handling process and adds some tree specific functions on repository. (closure, nestedset or materialized path) [https://github.com/Atlantic18/DoctrineExtensions/blob/master/doc/tree.md Gedmo] [https://github.com/KnpLabs/DoctrineBehaviors#tree KNP Labs] 88 91 * Sluggable, Translatable and Tree (Compatibility issue) 89 92 * https://github.com/Atlantic18/DoctrineExtensions/blob/master/doc/tree.md#nesting-translatable-and-sluggable-extensions 90 === = Uploadable ====93 === Uploadable === 91 94 * Provides file upload handling in entity fields [https://github.com/Atlantic18/DoctrineExtensions/blob/master/doc/uploadable.md Gedmo] 95 == Configuration and testing it == 96 = [https://phppackages.org/p/doctrine/doctrine-bundle doctrine/doctrine-bundle] 97 == Configuration and testing it == 98 === Mapping Configuration === 99 * When it appears unsure that ORM sees the mapped entities... 100 {{{#!sh 101 app$ php bin/console doctrine:mapping:info 102 }}} 103 {{{#!div class="important" 104 [Exception] You do not have any mapped Doctrine ORM entities according to the current configuration. If you have entities or mapping files you should check your mapping configuration for errors. [[span(Symfony ~3.2.1, Doctrine 2.4, style=float: right)]] 105 }}} 106 * It may be needed to set "auto_mapping" to true (in orm section of config.yml) or to configure the orm in detail. 107 * Once it is done: 108 {{{#!sh 109 app$ php bin/console doctrine:mapping:info 110 Found 1 mapped entities: 111 [OK] AppBundle\Entity\BlogPost 112 }}} 113 === Are the Mapped Entities in the Database Schema? === 114 {{{#!sh 115 app$ php bin/console doctrine:schema:validate 116 [Mapping] OK - The mapping files are correct. 117 [Database] FAIL - The database schema is not in sync with the current mapping file. 118 }}} 119 {{{#!sh 120 app$ php bin/console doctrine:schema:update --force 121 Updating database schema... 122 Database schema updated successfully! "1" queries were executed 123 }}} 124 {{{#!sh 125 app$ php bin/console doctrine:schema:validate 126 [Mapping] OK - The mapping files are correct. 127 [Database] OK - The database schema is in sync with the mapping files. 128 }}} 129 === Extract from command line history === 130 ==== 2017-01-11 ==== 131 php u018b_EasyAdmin.php doctrine:database:create 132 composer require Sensio/Generator-Bundle 133 {{{#!sh 134 app$ php u018b_EasyAdmin.php generate:bundle --namespace=AppBundle --bundle-name=AppBundle --format=annotation --dir=../src --no-interaction 135 }}} 136 {{{#!sh 137 app$ php u018b_EasyAdmin.php doctrine:generate:entity --entity="AppBundle:BlogPost" --fields="title:string(255) body:text draft:boolean" --no-interaction 138 }}} 139 {{{#!div class="important" 140 [InvalidArgumentException] Doctrine ORM Manager named "" does not exist. [[span(Symfony ~3.2.1, style=float: right)]] 141 }}} 142 {{{#!sh 143 app$ php u018b_EasyAdmin.php cache:clear 144 }}} 145 {{{#!div class="important" 146 [Symfony\Component\Config\Definition\Exception\InvalidTypeException] The configured class "AppBundle\Entity\BlogPost" for the path "easy_admin.entities.BlogPost" is no mapped entity. [[span(Symfony ~3.2.1, style=float: right)]] 147 }}} 148 {{{#!sh 149 app$ php u018b_EasyAdmin.php doctrine:schema:validate 150 [Mapping] OK - The mapping files are correct. 151 [Database] OK - The database schema is in sync with the mapping files. 152 }}} 153 {{{#!sh 154 app$ php u018b_EasyAdmin.php doctrine:generate:entities AppBundle/Entity/BlogPost 155 Generating entity "AppBundle\Entity\BlogPost" 156 }}} 157 {{{#!div class="important" 158 [Doctrine\ORM\Mapping\MappingException] Class "AppBundle\Entity\BlogPost" is not a valid entity or mapped super class. [[span(Symfony ~3.2.1, Doctrine 2.4, style=float: right)]] 159 }}} 160 {{{#!sh 161 app$ php u018b_EasyAdmin.php doctrine:generate:entities AppBundle/BlogPost 162 Generating entities for namespace "AppBundle\BlogPost" 163 }}} 164 {{{#!div class="important" 165 [RuntimeException] Namespace "AppBundle\BlogPost" does not contain any mapped entities. [[span(Symfony ~3.2.1, style=float: right)]] 166 }}} 167 {{{#!sh 168 app$ php u018b_EasyAdmin.php doctrine:mapping:info 169 }}} 170 {{{#!div class="important" 171 [Exception] You do not have any mapped Doctrine ORM entities according to the current configuration. If you have entities or mapping files you should check your mapping configuration for errors. [[span(Symfony ~3.2.1, Doctrine 2.4, style=float: right)]] 172 }}} 173 {{{#!sh 174 app$ php u018b_EasyAdmin.php doctrine:generate:entities AppBundle 175 Generating entities for bundle "AppBundle" 176 }}} 177 {{{#!div class="important" 178 [RuntimeException] Bundle "AppBundle" does not contain any mapped entities. [[span(Symfony ~3.2.1, style=float: right)]] 179 }}} 180 {{{#!sh 181 app$ php u018b_EasyAdmin.php doctrine:generate:entities AppBundle 182 Generating entities for bundle "AppBundle" 183 > backing up BlogPost.php to BlogPost.php~ 184 > generating AppBundle\Entity\BlogPost 185 }}} 186 {{{#!sh 187 app$ php u018b_EasyAdmin.php doctrine:mapping:info 188 Found 1 mapped entities: 189 [OK] AppBundle\Entity\BlogPost 190 }}} 191 {{{#!sh 192 app$ php u018b_EasyAdmin.php doctrine:schema:validate -vvv 193 [Mapping] OK - The mapping files are correct. 194 [Database] FAIL - The database schema is not in sync with the current mapping file. 195 }}} 196 {{{#!sh 197 app$ php u018b_EasyAdmin.php doctrine:schema:update --force 198 Updating database schema... 199 Database schema updated successfully! "1" queries were executed 200 }}} 201 {{{#!sh 202 app$ php u018b_EasyAdmin.php doctrine:schema:validate -vvv 203 [Mapping] OK - The mapping files are correct. 204 [Database] OK - The database schema is in sync with the mapping files. 205 }}} 206 {{{#!div class="important" 207 [[span(Symfony ~3.2.1, style=float: right)]] 208 }}} 209