Doctrine integration |
Hello jasonzig,
Quote:Maybe it's better in an another thread ? Documentation: Doctrine: https://www.doctrine-project.org/project...h-doctrine 1) SERVER: I'm using php 7.2.9, Nginx, MariaDb, phpmyadmin and composer. 2) CODEIGNITER: I used composer to install codeigniter, you can find more information: https://codeigniter4.github.io/userguide...poser.html Code: composer create-project codeigniter4/appstarter project-root -s rc => You should have a welcome page on your browser => I'm always also putting CodeIgniter in dev mode (Up to You) 3) INSTALLATION OF DOCTRINE: Composer to add doctrine: => composer.json (should be at the base of your project) https://www.doctrine-project.org/project...ject-setup You need to add: Code: { after in the console: 'composer install' and 'composer update' 4) CREATING THE DOCTRINE LIBRARIE: (FOR CI) =>App/Libraries/Doctrine.php PHP Code: <?php 5) CREATING THE FOLDERS: You need to create in the Models folder the following folders: 'Entities' => Models/Entities 'Proxies' => Models/Proxies 'Mappings' => Models/Mappings => The one you will use to create your tables 6) CREATING THE COMMAND LINE DOCTRINE: => In your App folder App/Doctrine.php PHP Code: <?php I'm also using a shortcut =>App/doctrine PHP Code: #!/usr/bin/env php 7) TEST THE COMMAND LINE: If everything is well setup you should be able to call doctrine in your console: By a simple 'php doctrine' (if you using the shortcut) or by a 'php Doctrine.php' PHP Code: php doctrine And you should get a : Code: Doctrine Command Line Interface 2.6.4-DEV 8) DOCTRINE AS A SERVICE: Quote:Special thanks to: MGatner and InsiteFx => App/Config/Services.php You need to edit your services.php to add doctrine as a serviceStill need some optimization i guess) PHP Code: class Services extends CoreServices 9) TEST : Now in your BaseController you can call this service and make a test: PHP Code: public function index() 10) HOW TO USE IT: Let's Create a test table: A)Generate an entity: In the folder 'Mappings' you can create a file called 'test' in yml: =>app/Models/Mappings/Entities.Test.dcm.yml Entities.Test.dcm.yml (Will be our 'test' table) Code: Entities\Test: B) Generate the class: Code: php doctrine orm:generate-entities Models C) Generate the proxies: Code: php doctrine orm:generate-proxies D) Create the table in our Dbb: Code: php doctrine orm:schema-tool:create Now you can just use doctrine in your controllers to get back information to update to insert etc: Quote:Check the Doctrine documentation for more information E) Get back the info: PHP Code: public function index() If there is something not clear or if you see something to change just let me know It's will be a pleasure to help you Regards, |
Messages In This Thread |
Doctrine integration - by ScientiFist - 11-16-2019, 08:26 PM
RE: Doctrine integration - by MGatner - 11-17-2019, 04:39 AM
RE: Doctrine integration - by InsiteFX - 11-17-2019, 04:50 AM
RE: Doctrine integration - by ScientiFist - 11-17-2019, 05:58 PM
RE: Doctrine integration - by MGatner - 11-17-2019, 05:10 AM
RE: Doctrine integration - by MGatner - 11-18-2019, 05:31 AM
RE: Doctrine integration - by ScientiFist - 11-18-2019, 10:34 AM
RE: Doctrine integration - by jasonzig - 11-29-2019, 08:20 AM
RE: Doctrine integration - by MGatner - 11-18-2019, 04:24 PM
RE: Doctrine integration - by ScientiFist - 11-26-2019, 06:29 PM
RE: Doctrine integration - by ScientiFist - 11-30-2019, 07:25 AM
RE: Doctrine integration - by MGatner - 12-01-2019, 05:36 AM
RE: Doctrine integration - by troturier - 12-06-2019, 06:28 AM
RE: Doctrine integration - by ScientiFist - 03-17-2020, 07:06 PM
RE: Doctrine integration - by foxbille - 05-10-2024, 11:51 PM
RE: Doctrine integration - by kenjis - 05-11-2024, 02:17 AM
RE: Doctrine integration - by foxbille - 05-11-2024, 05:24 AM
RE: Doctrine integration - by kenjis - 05-13-2024, 06:57 PM
RE: Doctrine integration - by foxbille - 05-18-2024, 09:14 AM
|