Outils pour utilisateurs

Outils du site


informatique:php:laravel

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
informatique:php:laravel [28/07/2021 17:25] – [Packages] Mes indispensables cyrilleinformatique:php:laravel [10/10/2023 19:38] (Version actuelle) – [Laravel] cyrille
Ligne 3: Ligne 3:
 [[http://laravel.com|Laravel]] The PHP Framework For Web Artisans. [[http://laravel.com|Laravel]] The PHP Framework For Web Artisans.
  
-Voir aussi [[/informatique/php/lumen|Lumen]] une version micro-framework de Laravel 5. +Voir aussi 
 +  * [[/informatique/php/lumen|Lumen]] une version micro-framework de Laravel 5. 
 +  * [[informatique/web/tailwind_css|informatique/web/Tailwind Css]]
 ===== Documentation ===== ===== Documentation =====
  
Ligne 27: Ligne 28:
   * [[https://laravel-news.com]]   * [[https://laravel-news.com]]
   * [[http://laraveldaily.com]]   * [[http://laraveldaily.com]]
 +  * https://laravel.io/
  
 ==== Handbooks & Cheats sheets==== ==== Handbooks & Cheats sheets====
Ligne 40: Ligne 42:
  
 ==== Tutoriels/Tutorials ==== ==== Tutoriels/Tutorials ====
 +
 +
 +[[https://dev.to/erikaheidi/creating-a-multi-user-to-do-application-with-laravel-jetstream-2p1k|Creating a Multi-User To-Do Application with Laravel JetStream]] 2020 with Laravel, Jetstream & Livewire
 +
 +=== Laravel 5 ===
  
 Tutoriels: Tutoriels:
Ligne 122: Ligne 129:
  
   * Le fabuleux "driver" pour l'inestimable [[http://datatables.net/|Datatables.net]] : [[https://github.com/yajra/laravel-datatables|yajra/laravel-datatables]] ; disponible pour Laravel 4.2.x à 8.x.x   * Le fabuleux "driver" pour l'inestimable [[http://datatables.net/|Datatables.net]] : [[https://github.com/yajra/laravel-datatables|yajra/laravel-datatables]] ; disponible pour Laravel 4.2.x à 8.x.x
 +  * Un "driver" pour [[http://phpdebugbar.com/|PhpDebugBar]] à installer dès le début de tout projet: [[https://github.com/barryvdh/laravel-debugbar|laravel-debugbar]]
 +  * ...
 ===== Admin panel ===== ===== Admin panel =====
  
-[[https://laravel-news.com/13-laravel-admin-panel-generators|13 Laravel Admin Panel Generators]] (2017)+  * [[https://laravel-news.com/13-laravel-admin-panel-generators|13 Laravel Admin Panel Generators]] (2017) 
 +  * [[https://codedthemes.medium.com/why-laravel-is-the-best-php-framework-list-of-laravel-admin-templates-2d49051308c6|List of Laravel Admin Templates]] (2021) 
 + 
 + 
 +  * Laravel creates a Vue admin panel from scratch (par balajidharma 2022) 
 +    * [[https://github.com/balajidharma/basic-laravel-admin-panel|basic-laravel-admin-panel]] 
 +      * Part 1: [[https://blog.devgenius.io/laravel-create-an-admin-panel-from-scratch-part-1-installation-8c11dae7e684|Installation]] 
 +      * Part 2: [[https://blog.devgenius.io/laravel-create-an-admin-panel-from-scratch-part-2-authentication-f0eb0bbd6139|Authentication]] 
 +      * Part 3: [[https://blog.devgenius.io/laravel-user-roles-and-permissions-6dbfd4abfcf8|user roles and permissions]] 
 +      * Part 4: [[https://blog.devgenius.io/basic-laravel-admin-panel-basic-laravel-crud-creation-for-permission-management-6bd93fb0e1a2|Basic Laravel CRUD creation for permission management]] 
 +      * Part 5: [[https://blog.devgenius.io/laravel-crud-access-control-based-on-role-and-permission-f190d03f1fa2|CRUD access control based on role and permission]] 
 +      * Part 6: [[https://blog.devgenius.io/implements-a-basic-search-filter-and-column-sort-with-pagination-in-laravel-crud-5e3c70fb12ac|Basic search filter and column sort with pagination]] 
 +      * Part 7: [[https://blog.devgenius.io/create-ui-for-role-management-to-laravel-admin-panel-dce72b09d2ea|Create UI for Role management]] 
 +      * Part 8: [[https://blog.devgenius.io/basic-laravel-admin-panel-user-management-crud-45f694ef60cc|Laravel user management CRUD]] 
 +      * ... -> Part 20. 
 +    * [[https://github.com/balajidharma/laravel-vue-admin-panel|laravel-vue-admin-panel]] 
 +      * part 1: [[https://blog.devgenius.io/laravel-creates-a-vue-admin-panel-from-scratch-part-1-installation-and-authentication-56c451d4d697|Installation and Steps for adding a Laravel Breeze and Spatie Laravel-permission packages]] 
 +      * part 2: [[https://blog.devgenius.io/create-laravel-crud-using-inertia-and-vue-3-list-page-with-search-and-pagination-c4a52b6501c3|Create Laravel CRUD using Inertia and Vue 3 - list page with search and pagination]] 
 +      * Part 3: [[https://blog.devgenius.io/create-laravel-crud-create-and-update-pages-using-inertia-and-vue-48162d8bf6ee|Create Laravel CRUD create and update pages using Inertia and Vue]] 
 +      * part 4: [[https://blog.devgenius.io/laravel-crud-column-sorting-with-inertia-and-vue-6bb16c30d3e0|Create Laravel CRUD Column Sorting with Inertia and Vue]] 
 +      * part 5: [[https://blog.devgenius.io/laravel-crud-authorization-with-inertia-and-vue-access-control-using-role-and-permission-bb718f0b3a78|Laravel CRUD Authorization with Inertia and Vue - Access control using role and permission]] 
 +        * [[https://spatie.be/docs/laravel-permission/|Spatie Laravel-permission]] 
 +        * [[https://inertiajs.com/|Inertia]] (//Inertia works much more like a classic server-side rendered application but, Inertia views are JavaScript page components written in React, Vue, or Svelte//) 
 +      * part 6: [[https://blog.devgenius.io/how-to-integrate-laravel-with-vue-tailwind-admin-one-dashboard-3753346181|How to integrate Laravel with Vue & Tailwind Admin One Dashboard]] 
 +        * [[https://github.com/justboil/admin-one-vue-tailwind|Admin One]] - Free Vue 3.x Tailwind 3.x Admin Dashboard 
 +      * Part 7: [[https://blog.devgenius.io/laravel-applies-admin-one-dashboard-template-to-crud-e187a6cce50|Laravel applies Admin One dashboard template to CRUD]] 
 +      * Part 8: [[https://blog.devgenius.io/laravel-creates-a-profile-update-page-with-inertia-and-vue-6c6f0d7a01ef|Laravel creates a profile update page with Inertia and Vue]]
  
 Menus, CRUD & more : Menus, CRUD & more :
  
 +Préférés:
   * [[https://orchid.software/|Laravel Orchid]] Develop web applications not admin panels - Laravel Orchid n'est pas une "solution clé en main". Vous devez posséder des compétences en codage pour l'utiliser. Il a été conçu pour faciliter la vie des développeurs lors de la construction de systèmes complexes, et non pour vous en fournir un tout prêt à l'emploi.   * [[https://orchid.software/|Laravel Orchid]] Develop web applications not admin panels - Laravel Orchid n'est pas une "solution clé en main". Vous devez posséder des compétences en codage pour l'utiliser. Il a été conçu pour faciliter la vie des développeurs lors de la construction de systèmes complexes, et non pour vous en fournir un tout prêt à l'emploi.
 +    * [[https://orchid.software/en/docs/packages/crud/|CRUD orchid package]]
   * [[https://voyager.devdojo.com|Voyager]] -> Laravel 6, 7, 8 <del>https://laravelvoyager.com</del>, many contributors   * [[https://voyager.devdojo.com|Voyager]] -> Laravel 6, 7, 8 <del>https://laravelvoyager.com</del>, many contributors
     * [[https://voyager-docs.devdojo.com/|doc]], [[https://github.com/the-control-group/voyager|code]], [[https://github.com/the-control-group/voyager/discussions/|discussions/forum]]     * [[https://voyager-docs.devdojo.com/|doc]], [[https://github.com/the-control-group/voyager|code]], [[https://github.com/the-control-group/voyager/discussions/|discussions/forum]]
 +
 +Autres:
 +  * [[http://labs.infyom.com/laravelgenerator/|Laravel Generator]] by infyom.com
 +    * [[https://www.infyom.com/open-source/laravelgenerator/docs|doc]], [[https://github.com/InfyOmLabs/laravel-generator|code]], [[https://github.com/InfyOmLabs/laravel-generator/graphs/contributors|60 contributors]], [[https://opencollective.com/infyomlabs|sponsors/backers]]
   * [[http://laraAdmin.com|LaraAdmin]] -> laravel 5   * [[http://laraAdmin.com|LaraAdmin]] -> laravel 5
     * [[https://laraadmin.com/docs|doc]], [[https://github.com/dwijitsolutions/laraadmin|code]]     * [[https://laraadmin.com/docs|doc]], [[https://github.com/dwijitsolutions/laraadmin|code]]
Ligne 136: Ligne 177:
     * [[https://filamentadmin.com/docs/|doc]], [[https://github.com/laravel-filament/filament|code]]     * [[https://filamentadmin.com/docs/|doc]], [[https://github.com/laravel-filament/filament|code]]
   * https://silverbux.github.io/laravel-angular-admin/ Laravel + Angularjs + Bootstrap + AdminLTE binded by Gulp workflow Admin Dashboard Boilerplate. Plus Oauth and JWT authentication on the side.   * https://silverbux.github.io/laravel-angular-admin/ Laravel + Angularjs + Bootstrap + AdminLTE binded by Gulp workflow Admin Dashboard Boilerplate. Plus Oauth and JWT authentication on the side.
-  * [[http://labs.infyom.com/laravelgenerator/|Laravel Generator]] 
-    * [[https://www.infyom.com/open-source/laravelgenerator/docs|doc]], [[https://github.com/InfyOmLabs/laravel-generator|code]], [[https://github.com/InfyOmLabs/laravel-generator/graphs/contributors|60 contributors]], [[https://opencollective.com/infyomlabs|sponsors/backers]] 
  
 Not free: Not free:
   * https://quickadminpanel.com   * https://quickadminpanel.com
     * [[https://quickadminpanel.com/blog/free-mini-course-how-to-create-admin-panel-in-laravel-5-4/|How To Create Admin Panel in pure Laravel 5.4]]     * [[https://quickadminpanel.com/blog/free-mini-course-how-to-create-admin-panel-in-laravel-5-4/|How To Create Admin Panel in pure Laravel 5.4]]
 +  * [[https://codedthemes.com/item/datta-able-laravel-admin-dashboard/|Datta Able Laravel Admin Dashboard]]
   * [[https://codecanyon.net/item/josh-laravel-admin-template-front-end-crud/8754542|Josh]] - Laravel Admin Template + Front End + CRUD   * [[https://codecanyon.net/item/josh-laravel-admin-template-front-end-crud/8754542|Josh]] - Laravel Admin Template + Front End + CRUD
     * Builders: Form, Button, Page     * Builders: Form, Button, Page
   * [[https://backpackforlaravel.com|BackpackForLaravel]] but open source [[https://github.com/Laravel-Backpack]]   * [[https://backpackforlaravel.com|BackpackForLaravel]] but open source [[https://github.com/Laravel-Backpack]]
-    * Free for non commercial, 399€ht for commercial+    * [[https://backpackforlaravel.com/docs/5.x/features-free-vs-paid|Features (Free vs Paid)]] 
  
 Unmaintened: Unmaintened:
   * http://laraveldaily.com/packages/quickadmin/   * http://laraveldaily.com/packages/quickadmin/
   * http://laravelpanel.com   * http://laravelpanel.com
 +
 +Only templates:
 +  * https://coreui.io/
  
 ===== Validation ===== ===== Validation =====
Ligne 180: Ligne 224:
 </code> </code>
  
 +==== Client side validation ====
 +
 +=== Avec JQuery ===
 +
 +Le package [[https://github.com/proengsoft/laravel-jsvalidation|proengsoft/laravel-jsvalidation]] fait la passerelle entre Laravel et "jQuery Validation Plugin" [[https://jqueryvalidation.org/|jqueryvalidation]]. La majorité des règles de validation et ainsi que leurs messages d'erreur sont compatibles, c'est excellent.
 +
 +=== Avec Alpine.Js ===
 +
 +Rien trouvé. Il y a le [[https://medium.com/@just_turquoise_armadillo_355/javascript-form-validation-with-alpine-js-and-ionide-js-a17b6d23fbf8|micro-framework Ionide]] mais pas compatible avec Laravel, notamment le format des messages d'erreur.
 +=== Avec Vue.js ===
 +
 +Pas de réponse à ma question [[https://laracasts.com/discuss/channels/vue/validation-vue-package-compatible-with-laravel-validator-rules|Validation VUE package compatible with Laravel Validator Rules]].
 +
 +Packages à évaluer:
 +  * [[https://www.npmjs.com/package/@vuelidate/validators|vuelidate/validators]]
 +  * [[https://vuelidate-next.netlify.app/|Vuelidate 2]] with [[https://www.npmjs.com/package/@vuelidate/core|vuelidate/core]] and [[https://www.npmjs.com/package/@vuelidate/validators|vuelidate/validators]]
 +  * [[https://vee-validate.logaretm.com/v4/|vee-validate]]
 +    * pour inspiration [[https://github.com/RobertGlynWilliams/vee-validate-laravel|vee-validate-laravel]], [[https://github.com/cretueusebiu/vform|cretueusebiu/vform]]
 +    * [[https://vee-validate.logaretm.com/v4/guide/global-validators|Global validators]] (Laravel-like syntax) through @vee-validate/rules
 +    * [[https://vee-validate.logaretm.com/v4/guide/components/handling-forms|handling-forms]] pour le schéma de validation, les valeurs initiales et les différentes façons de gérer le submit
 +    * [[https://vee-validate.logaretm.com/v4/api/use-form#composable-api|Composable API]]
 +      * Permet de définir les erreurs initiales au mount avec ''[[https://vee-validate.logaretm.com/v4/guide/composition-api/handling-forms#initial-errors|initialErrors]]''
 +  * [[https://github.com/zhorton34/vuejs-form|zhorton34/vuejs-form]] est inspiré de Laravel :-)
 ===== Data, ORM, Eloquent ===== ===== Data, ORM, Eloquent =====
  
   * [[https://laravel-news.com/2015/09/how-to-add-multilingual-support-to-eloquent/|How To Add Multilingual Support to Eloquent]]   * [[https://laravel-news.com/2015/09/how-to-add-multilingual-support-to-eloquent/|How To Add Multilingual Support to Eloquent]]
   * [[https://github.com/menthol/laravel-relationships-examples|All Laravel relationships implemented in a ready to try Laravel skeleton app]]   * [[https://github.com/menthol/laravel-relationships-examples|All Laravel relationships implemented in a ready to try Laravel skeleton app]]
 +
 +==== Boot & initialize Trait ====
 +
 +Eloquent peut booter et initialiser les Traits utilisés par les modèles, en utilisant la méthode de nommage **boot<Trait>** and **initialize<Trait>**,
 +
 +https://orkhan.dev/2020/08/17/using-traits-to-boot-and-initialize-eloquent-models/
  
 ==== Model validation ==== ==== Model validation ====
Ligne 193: Ligne 266:
     * [[https://github.com/Waavi/model|WaaviModel]] uses Laravel's Validator class, therefore validation rules, custom messages and custom validation methods are all available.     * [[https://github.com/Waavi/model|WaaviModel]] uses Laravel's Validator class, therefore validation rules, custom messages and custom validation methods are all available.
  
 +Discussion about [[https://grokstar.dev/open-source/2021/07/laravel-validation-options-model-form-request-or-livewire/|Laravel Validation Options – Model, Form Request or Livewire?]] 2021
 +  * Je préfère clairement exprimer les règles dans le Model et qu'elles soient vérifiées/validées à l'enregistrement. Le package [[https://packagist.org/packages/watson/validating|watson/validating]] de [[https://www.dwightwatson.com/|Dwight Watson]] le fait parfaitement. Ces règles gérées au niveau du Model peuvent être reprises pour d'autres techniques (''Model::getRules()'') tout en s'assurant que le Model reste "safe".
 === On client side (javascript) === === On client side (javascript) ===
  
Ligne 216: Ligne 291:
  
 ==== Divers ==== ==== Divers ====
 +
 +=== Cursor() vs get() ===
 +
 +La méthode ''cursor()'' au lieu de ''get()'' fonctionne vraiment :-)
 +
 +Comparaison de la consommation mémoire (//avec la même requête//):
 +|                  ^ get()       ^ cursor()    ^
 +| memory_get_usage | 29 360 128  | 12 582 912  |
  
 === Nested tree === === Nested tree ===
Ligne 427: Ligne 510:
  
 **Nota bene** Dans le cas d'un composant qui n'est pas utilisé dans toutes les requêtes, on va préférer le charger que si besoin : [[https://laravel.com/docs/5.2/providers#deferred-providers|Deferred Providers]] (aka lazy loading) **Nota bene** Dans le cas d'un composant qui n'est pas utilisé dans toutes les requêtes, on va préférer le charger que si besoin : [[https://laravel.com/docs/5.2/providers#deferred-providers|Deferred Providers]] (aka lazy loading)
 +
 +==== Parent component ====
 +
 +La directive Blade ''@aware'' permet d'accéder aux propriétés du composant ''parent''. Attention, les propriétés par défaut qui ne sont pas explicitement attribuées au tag du composant parent ne seront pas accessibles.
 +
 +  * https://laravel.com/docs/10.x/blade#accessing-parent-data
  
 ==== Twig template engine with Laravel ==== ==== Twig template engine with Laravel ====
  
 [[https://github.com/rcrowe/TwigBridge|Give the power of Twig to Laravel]] 4 & 5. [[https://github.com/rcrowe/TwigBridge|Give the power of Twig to Laravel]] 4 & 5.
 +
 +==== Inertia ====
 +
 +https://inertiajs.com/how-it-works
 +
 +Inertia replaces your application's view layer. Instead of using server-side rendering via Blade templates, the views returned by your application are JavaScript page components. This allows you to build your entire front-end using React, Vue, or Svelte while still enjoying the productivity of Laravel or your preferred server-side framework.
 +
 +At its core, Inertia is essentially a client-side routing library. It allows you to make page visits without forcing a full page reload. This is done using the ''<Link>'' component, a light-weight wrapper around a normal anchor link. When you click an Inertia link, Inertia intercepts the click and makes the visit via XHR instead. You can even make these visits programmatically in JavaScript using ''router.visit()''.
 +
 +
  
 ==== Wysiwyg editor ==== ==== Wysiwyg editor ====
Ligne 476: Ligne 575:
  
   * [[http://laravelcollective.com/docs/5.0/ssh|Remote SSH]]   * [[http://laravelcollective.com/docs/5.0/ssh|Remote SSH]]
 +
 +==== Command ====
 +
 +<code>
 +$this->getOutput()->isQuiet()       - no verbosity is set                                   (no option set)
 +$this->getOutput()->isVerbose()     - if the level is quiet or verbose                      (-v)
 +$this->getOutput()->isVeryVerbose() - if the level is very verbose, verbose or quiet        (-vv)
 +$this->getOutput()->isDebug()       - if the level is debug, very verbose, verbose or quiet (-vvv)
 +</code>
  
 ==== Cache ==== ==== Cache ====
Ligne 528: Ligne 636:
 ==== Error catcher ==== ==== Error catcher ====
  
-[[:informatique:php::informatique:error_services|informatique]]/error_services+[[/informatique:error_services|informatique/error_services]]
  
 Avec [[https://sentry.io|Sentry.io]] : Avec [[https://sentry.io|Sentry.io]] :
Ligne 535: Ligne 643:
   * [[https://docs.sentry.io/clients/php/integrations/laravel/|https://docs.sentry.io/clients/php/integrations/laravel/]]   * [[https://docs.sentry.io/clients/php/integrations/laravel/|https://docs.sentry.io/clients/php/integrations/laravel/]]
  
 +==== PhpDoc ====
 +
 +Merci à [[https://darkghosthunter.medium.com/|Italo Baeza Cabrera]] pour [[https://darkghosthunter.medium.com/laravel-phpdocs-for-models-everyone-should-have-9fe0d8349525|Laravel: PHPDocs for Models everyone should have]]
 +
 +<code>
 +/**
 + * @mixin \Illuminate\Database\Eloquent\Builder
 + *
 + * @method static \Illuminate\Database\Eloquent\Builder|static query()
 + * @method static static make(array $attributes = [])
 + * @method static static create(array $attributes = [])
 + * @method static static forceCreate(array $attributes)
 + * @method \App\Models\User firstOrNew(array $attributes = [], array $values = [])
 + * @method \App\Models\User firstOrFail($columns = ['*'])
 + * @method \App\Models\User firstOrCreate(array $attributes, array $values = [])
 + * @method \App\Models\User firstOr($columns = ['*'], \Closure $callback = null)
 + * @method \App\Models\User firstWhere($column, $operator = null, $value = null, $boolean = 'and')
 + * @method \App\Models\User updateOrCreate(array $attributes, array $values = [])
 + * @method null|static first($columns = ['*'])
 + * @method static static findOrFail($id, $columns = ['*'])
 + * @method static static findOrNew($id, $columns = ['*'])
 + * @method static null|static find($id, $columns = ['*'])
 + *
 + * @property-read int $id
 + *
 + * @property string $first_name
 + * @property string $last_name
 + * @property \Illuminate\Support\Collection|null $favorite_songs
 + * @property int $stars
 + *
 + * @property-read \Illuminate\Support\Carbon $created_at
 + * @property-read \Illuminate\Support\Carbon $updated_at
 + * @property-read \Illuminate\Support\Carbon $deleted_at
 + *
 + * @property-read string $full_name
 + *
 + * @property-read \App\Models\Avatar $avatar
 + * @property-read \App\Models\Biography|null $biography
 + * @property-read \Illuminate\Database\Eloquent\Collection|\App\Models\Post[] $posts
 + *
 + * @method \Illuminate\Database\Eloquent\Builder|static age(int $age)
 + */
 +</code>
  
 ==== Wordpress and Laravel ==== ==== Wordpress and Laravel ====
Ligne 565: Ligne 716:
 ==== Tools ==== ==== Tools ====
  
 +  * [[https://underground.works/clockwork/|ClockWork]] a l'air plus puissant que Laravel Debugbar ...
   * [[https://github.com/barryvdh/laravel-debugbar|Laravel Debugbar]]   * [[https://github.com/barryvdh/laravel-debugbar|Laravel Debugbar]]
  
Ligne 575: Ligne 727:
  
 {{ :informatique:php:laravel:laravel-queue.png?nolink&400|}} {{ :informatique:php:laravel:laravel-queue.png?nolink&400|}}
 +
 +  * [[https://blog.devgenius.io/handling-asynchronous-errors-in-php-with-laravel-queues-symfony-messenger-and-ecotone-9becba7fba46|Handling asynchronous errors in PHP with Laravel Queues, Symfony Messenger and Ecotone]]
 +
  
 === Laravel Queue === === Laravel Queue ===
Ligne 581: Ligne 736:
   * [[https://voltagead.com/the-basics-of-laravel-queues-using-redis-and-horizon/|The basics of Laravel Queues using Redis and Horizon]]   * [[https://voltagead.com/the-basics-of-laravel-queues-using-redis-and-horizon/|The basics of Laravel Queues using Redis and Horizon]]
   * package [[https://github.com/imTigger/laravel-job-status|Laravel Job Status]] add ability to track Job progress, status and result dispatched to Queue   * package [[https://github.com/imTigger/laravel-job-status|Laravel Job Status]] add ability to track Job progress, status and result dispatched to Queue
 +
 +When the queued job is being pulled out from the queue, the CallQueuedListener will check if it’s using the [[https://laravel.com/docs/10.x/events#manually-interacting-with-the-queue|InteractsWithQueue]] trait, and if it is, the framework will inject the underlying “job” instance inside.
  
 More about [[.laravel:horizon|horizon]]. More about [[.laravel:horizon|horizon]].
informatique/php/laravel.1627485900.txt.gz · Dernière modification : 28/07/2021 17:25 de cyrille

Sauf mention contraire, le contenu de ce wiki est placé sous les termes de la licence suivante : CC0 1.0 Universal
CC0 1.0 Universal Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki