====== Laravel ====== [[http://laravel.com|Laravel]] The PHP Framework For Web Artisans. Voir aussi : * [[/informatique/php/lumen|Lumen]] une version micro-framework de Laravel 5. * [[informatique/web/tailwind_css|informatique/web/Tailwind Css]] ===== Documentation ===== * [[https://laravel.com/docs/8.x|Laravel 8.x]] * [[https://laravel.sillo.org/la-tall-stack/|La TALL Stack]] Tailwind CSS, [[/informatique/javascript/AlpineJS|AlpineJS]], Laravel et Livewire * [[https://github.com/laravel-frontend-presets|laravel-frontend-presets]], en plus des quelques ui presets fournis par Laravel pour un simple dashboard ou la tall stack ou ... de simples mais jolis dashboards comme [[https://www.creative-tim.com/live/paper-dashboard-laravel|paper-dashboard-laravel]] * [[https://laravel.com/docs/5.3|Laravel 5.3]] * [[http://devmarketer.io/learn/new-laravel-5-3-part1-small-changes/|What is New in Laravel 5.3?]] * [[https://laravel.com/docs/5.2|Laravel 5.2]] * [[http://blog.laravel.com/?p=53|Laravel 5.2 new features]] * [[https://mattstauffer.co/blog/series/new-features-in-laravel-5-2|New Features in Laravel 5.2]] by Matt Stauffer * Laravel 5.0 * [[https://mattstauffer.co/blog/series/new-features-in-laravel-5.0|New Features in Laravel 5.0]] * [[https://mattstauffer.co/blog/laravel-5.0-form-requests|Laravel 5.0 - Form Requests]] Discussion: * [[https://larachat.slack.com|LaraChat]] on Slack * [[https://laracasts.com/discuss|Laracasts forum]] News * [[https://laravel-news.com|laravel-news.com]] * [[http://laraveldaily.com|laraveldaily.com]] * [[https://laravel.io/|laravel.io]] * [[https://madewithlaravel.com|madewithlaravel.com]] ==== Handbooks & Cheats sheets==== * [[http://cheats.jesse-obrien.ca/|Cheats sheet]] * [[http://www.howtosolvenow.com/category/language/php/larevel|How To Solve Now, Laravel]] * [[http://www.howtosolvenow.com/laravel-app-log-urls-and-events/|Laravel App, Log, URLs and Events]] * [[http://www.howtosolvenow.com/laravel-schema/|Laravel Schema]] * [[http://www.howtosolvenow.com/laravel-eloquent/|Laravel Eloquent]] * [[http://www.howtosolvenow.com/laravel-cache-cookies-and-sessions/|Laravel Cache, Cookies and Sessions]] * [[http://www.howtosolvenow.com/laravel-request-response-and-redirect/|Laravel Request, Response and Redirect]] ==== 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: * [[https://laravel.sillo.org|laravel.sillo.org]] des articles en français et d'excellente qualité * [[https://laravel.sillo.org/livewire-introduction/|Livewire – introduction]] (2020) * [[https://laravel.sillo.org/laravel-5/|laravel 5x]] * [[http://laravel.sillo.org/cours-laravel-5-3-plus-loin-les-tests-unitaires/|Cours Laravel 5.3 – plus loin – les tests unitaires]] * [[http://laravel.sillo.org/cours-laravel-5-3-plus-loin-les-evenements/|http://laravel.sillo.org/cours-laravel-5-3-plus-loin-les-evenements/]] * https://openclassrooms.com/courses/decouvrez-le-framework-php-laravel-1 * [[http://laravel.sl-creation.org]] * [[http://laravel.sl-creation.org/creer-une-application-les-donnees/|Apprentissage de la version 5 de Laravel]] : un blog avec frontend et backend, avec bootstrap. Exemples: * [[https://github.com/bestmomo/laravel5-3-example/|bestmomo/laravel5-3-example]] with: Home page ; Custom error pages 403, 404 and 503 ; Authentication (registration, login, logout, password reset, mail confirmation, throttle) ; Users roles : administrator (all access), redactor (create and edit post, upload and use medias in personnal directory), and user (create comment in blog) ; Blog with comments ; Search in posts ; Tags on posts ; Contact us page ; Admin dashboard with messages, users, posts, roles and comments ; Users admin (roles filter, show, edit, delete, create, blog report) ; Posts admin (list with dynamic order, show, edit, delete, create) ; Multi users medias gestion ; Localization ; Application tests ; Use of new notifications to send emails and notify redactors for new comments Tutorials: * [[https://laravel.com/docs/5.2/quickstart-intermediate|Intermediate Task List]] (Laravel 5.2) * [[http://www.codetutorial.io/tutorial/laravel-5/|Laravel 5 tutorials]] : GEO Spatial MySQL in Laravel 5, Laravel 5 REST Api Basic Authentication, Laravel 5 and AngularJS, Laravel 5 and Socket.io * [[https://github.com/menthol/laravel-relationships-examples|All Laravel relationships implemented in a ready to try Laravel skeleton app]] * de bon articles récents sur des sujets pertinents * [[http://goodheads.io/tag/laravel-5/|goodheads.io/tag/laravel-5]] * [[http://culttt.com|culttt.com]], notamment sur Elixir * Créer des packages pour Laravel: * [[http://laraveldaily.com/how-to-create-a-laravel-5-package-in-10-easy-steps/|How to create a Laravel 5 package in 10 easy steps]] * [[https://websanova.com/blog/laravel/creating-a-new-package-in-laravel-5-part-1-package-workflow|Creating a Laravel 5.x Package]] * [[https://medium.com/@tabacitu/creating-laravel-5-packages-for-dummies-ec6a4ded2e93|Creating Laravel 5 Packages for dummies]] * voir [[#vuejs|Laravel et VUE.js]] * [[https://scotch.io/tutorials/how-to-process-tweets-in-real-time-with-laravel|How To Process Tweets in Real-Time with Laravel]] that implements Job, Command, Queue and of course Twitter streaming api with [[https://github.com/fennb/phirehose/|Phirehose]] * [[https://laravel-news.com/authorization-gates|An Introduction to Laravel Authorization Gates]] * [[https://www.toptal.com/laravel/handling-intensive-tasks-with-laravel?|Handling Intensive Tasks with Laravel]] (async queue processing, Excel) * [[https://www.larashout.com/laravel-mix|Laravel Mix – The Complete Guide]] ==== Fait avec ou pour Laravel ==== === Free === Starters: * [[https://github.com/unicodeveloper/laravel-hackathon-starter|laravel-hackathon-starter]] * [[/informatique/php/Enso|Enso]] Full featured Single Page Application [[/glossaire/SPA|SPA]] boilerplate, Laravel, Vue, Bulma. [[https://docs.laravel-enso.com/packages/|Plein de packages]] pour faire plein de choses. source d'inspiration. * https://github.com/nasirkhan/laravel-starter CMS : * [[/informatique/php/October|October]] * [[/informatique/php/AsgardCms|AsgardCms]] === No Free === * [[https://laravel-bap.com/features/|Laravel BAP]] Modular Backend Application Platform + Example CRM with 17 modules === Unknow === * [[https://cnvs.io|Canvas]] Simple, Powerful Blog Publishing Platform * [[https://github.com/php-tmdb/laravel|php-tmdb/laravel]] A Laraval Package for use together with the php-tmdb/api TMDB Wrapper (TMDB: The Movie Database) * [[https://github.com/summerblue/phphub5|summerblue/phphub5]] PHPHub Ver 5 is a Forum project Powered by Laravel 5.1 * [[https://github.com/BootstrapCMS/CMS|BootstrapCMS]] * [[https://laravel-news.com/2016/11/laravel-cms-packages/|A Roundup of Laravel CMS Packages]] (October, Statamic, Pyro, …) * [[https://github.com/TimothyDJones/awesome-laravel|A curated list of delightful Laravel PHP framework packages and resources]] === CMS on top of Laravel === * [[https://statamic.com|Statamic]] * [[http://www.atlantis-cms.com|Atlantis CMS]] * [[http://www.lavalite.org|Lavalite]] Portail class (admin,user,client,public) Multilingual CMS built on Laravel 5.3 (Multiauth & API enabled) * PyroCMS * https://prismic.io ? === Unmaintened, abandonned === * [[https://github.com/BootstrapCMS|Bootstrap CMS]] - Latest commit on 28 Jun 2016 ==== Packages ==== * [[http://packalyst.com/|Packalyst]] is a directory of Packages for your Laravel projects * [[https://madewithlaravel.com|made with Laravel]] * [[https://laravel-bap.com/10-plus-laravel-packages-for-building-laravel-apps/|10+ Laravel Packages for Building Laravel Apps]] === Mes indispensables === Actuellement pour Laravel 5.x, à voir si ces packages ont survécus :-) * 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 ===== * [[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 : Préférés: * [[https://filamentphp.com/|Filament]] * [[https://filamentphp.com/docs|docs]], [[https://github.com/filamentphp/filament|code]] * [[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 https://laravelvoyager.com, 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]] 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 * [[https://laraadmin.com/docs|doc]], [[https://github.com/dwijitsolutions/laraadmin|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. Not free: * 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://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 * Builders: Form, Button, Page * [[https://backpackforlaravel.com|BackpackForLaravel]] but open source [[https://github.com/Laravel-Backpack]] * [[https://backpackforlaravel.com/docs/5.x/features-free-vs-paid|Features (Free vs Paid)]] Unmaintened: * http://laraveldaily.com/packages/quickadmin/ * http://laravelpanel.com Only templates: * https://coreui.io/ ===== Validation ===== Voir aussi [[#model_validation|model validation]] * [[https://mattstauffer.co/blog/form-array-validation-in-laravel-5-2|Form array validation]] in Laravel 5.2 ==== CSRF, XSS, SQL ... ==== * [[http://www.easylaravelbook.com/blog/2015/07/22/how-laravel-5-prevents-sql-injection-cross-site-request-forgery-and-cross-site-scripting/|How Laravel 5 Prevents SQL Injection, Cross-Site Request Forgery, and Cross-Site Scripting]] * [[http://laravel-tricks.com/tricks/laravel-5-xss-middleware|Laravel 5 XSS Middleware]] ==== Excluding Routes from the CSRF Middleware in Laravel 5.1 ==== Dans la documentation: [[https://laravel.com/docs/5.2/routing#csrf-excluding-uris|routing csrf-excluding-uris]] It's now super easy to exclude specific routes from your CSRF middleware: \\ //source: [[https://mattstauffer.co/blog/excluding-routes-from-the-csrf-middleware-in-laravel-5.1]]// Plus d'information : [[https://laravel-news.com/2015/06/excluding-routes-from-the-csrf-middleware/|Excluding Routes from the CSRF Middleware]] // app/Http/Middleware/VerifyCsrfToken protected $except = [ 'webhook/*' ]; ==== 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 ===== * [[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]] ==== Boot & initialize Trait ==== Eloquent peut booter et initialiser les Traits utilisés par les modèles, en utilisant la méthode de nommage **boot** and **initialize**, https://orkhan.dev/2020/08/17/using-traits-to-boot-and-initialize-eloquent-models/ ==== Model validation ==== * [[https://github.com/esensi/model|Esensi Model Traits Package]] * Peut-être moins complets (moins bien ?) * [[https://github.com/laravelbook/ardent|Ardent]] * an deprecated Laravel 5's fork [[https://packagist.org/packages/aziz/smartmodel|aziz/smartmodel]] * [[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) === Utiliser côté client les règles de validation et messages d'erreurs définis pour les Models. * [[http://laravel-jsvalidation.memorylimit.net|Laravel 5 Javascript Validation]] ([[https://github.com/proengsoft/laravel-jsvalidation|source code]]) allows to reuse your Laravel Validation Rules, Messages, FormRequest and Validators to validate forms transparently in client side without need to write any Javascript code or use HTML Builder Class. You can validate forms automatically referencing it to your defined validations. The messages are loaded from your validators and translated according your Localization preferences. * Laravel Validation For Client Side https://github.com/bllim/laravalid * (abandoned) https://github.com/bllim/laravel-to-jquery-validation === Autres === ModelForm, [[https://github.com/andersondanilo/modelform|Laravel implementation of Django Forms]], is a PHP Form Abstraction for Laravel based on Django **Forms and Formset**. ==== versions des données ==== Gérer les versions des données * https://github.com/VentureCraft/revisionable * store in a "versions" table * https://github.com/awjudd/l4-revisable * https://github.com/mpociot/versionable * store in a "versions" table ==== 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 === Gestion d'arborescence (Nested tree structure, Nested category) : * [[https://github.com/lazychaser/laravel-nestedset|Effective tree structures in Laravel 4-5]] * [[https://packagist.org/packages/kalnoy/nestedset|kalnoy/nestedset]] === import/export & bulk === * [[http://www.maatwebsite.nl/laravel-excel/docs|Laravel Excel]] * https://github.com/goodby/csv ===Doctrine=== Doctrine avec Laravel: http://www.laraveldoctrine.org - Problème: à cause de la forte dépendance de Laravel avec Eloquent, les packages externes continueront d'utiliser Eloquent. === SQL View === * [[http://programmingarehard.com/2013/11/10/eloquent_and_views.html/|Eloquent and SQL Views]] === GraphQL === * [[https://api-platform.com/docs/laravel/|API Platform]] * Laravel ou Symfony * expose your Eloquent models in minutes with Anotation as: * REST API JSON-LD/RDF, JSON:API, HAL, and many RFCs… * GraphQL API * automatically expose an OpenAPI specification (formerly Swagger), dynamically generated from your Eloquent models and always up to date * benefits from the API Platform JavaScript tools: admin and create client (supports Next/React, Nuxt/Vue.js, Quasar, Vuetify and more!) * [[https://graphqlite.thecodingmachine.io/|GraphQLite]] A PHP library that allows you to write your GraphQL queries in simple-to-write controllers * Create a complete GraphQL API by simply annotating your PHP classes * Framework agnostic, but Symfony, Laravel and PSR-15 bindings available! * Comes with batteries included: queries, mutations, subscriptions, mapping of arrays / iterators, file uploads, security, validation, extendable types and more! * [[https://lighthouse-php.com/|Lighthouse]] A framework for serving GraphQL from Laravel * il faut maintenir un fichier contenant le schema ===== Authentification ===== ==== Multi-Auth ==== **Laravel 5.2**, you may define additional authentication drivers as well define **multiple authenticatable models or user tables**, and control their authentication process separately from each other. For example, if your application has one database table for “admin” users and one database table for “student” users, you may now use the Auth methods to authenticate against each of these tables separately. * http://stackoverflow.com/questions/34614753/can-anyone-explain-laravel-5-2-multi-auth-with-example * https://github.com/rizalafani/Laravel-5.1-Multi-Auth-Example ==== Authentication Scaffolding ==== **Laravel 5.2**: This command will generate plain, Bootstrap compatible views for user login, registration, and password reset. The command will also update your routes file with the appropriate routes. Note: This feature is **only meant to be used on new applications**, not during application upgrades. php artisan make:auth === Manage User last login datetime === // Migration $table->dateTime('last_login_at')->nullable(); class User { ... protected $fillable = [ 'name', 'email', 'password','last_login_at' ]; protected $dates = [ 'created_at', 'updated_at', 'last_login_at' ]; } class LoginController { ... function authenticated( Request $request, $user ) { $user->timestamps = false; $user->update([ 'last_login_at' => Carbon::now(), ]); } ==== OAuth ==== [[https://laravel.com/docs/5.4/passport|Laravel Passport]] est le serveur OAuth officiel. * Essai réussi pour s'authentifier sur Grafana via une app Laravel. Autres: * [[https://github.com/adamwathan/eloquent-oauth|https://github.com/adamwathan/eloquent-oauth]] * [[https://github.com/adamwathan/eloquent-oauth-l5|https://github.com/adamwathan/eloquent-oauth-l5]] * [[https://github.com/laravel/socialite|https://github.com/laravel/socialite]] * [[http://socialiteproviders.github.io/|http://socialiteproviders.github.io/]] === Passing parameters to Middleware === //source: [[https://mattstauffer.co/blog/passing-parameters-to-middleware-in-laravel-5.1]]// Using parameterized middleware in the route defintion. When you're adding middleware to a route definition, you'd normally set it like this: Route::get('company', ['middleware' => 'auth', function () { return view('company.admin'); }]); So, let's add in our parameter to show that the user must have the owner role: Route::get('company', ['middleware' => 'auth:owner', function () { return view('company.admin'); }]); Note that you can also pass multiple parameters as a comma-separated list: Route::get('company', ['middleware' => 'auth:owner,view', function () { return view('company.admin'); }]); ==== How to disable remember me token ? ==== Simply overload some methods: class User extends BaseModel implements UserInterface, RemindableInterface { ... public function getRememberToken(){ return null; // not supported } public function setRememberToken($value){ // not supported } public function getRememberTokenName(){ return null; // not supported } /** * Overrides the method to ignore the remember token. */ public function setAttribute($key, $value) { $isRememberTokenAttribute = $key == $this->getRememberTokenName(); if (!$isRememberTokenAttribute) { parent::setAttribute($key, $value); } } ... ==== Sentinel ==== https://cartalyst.com/manual/sentinel A modern and framework agnostic authorization and authentication package featuring: * roles, permissions, * custom hashing algorithms and additional security features. The package follows the FIG standard [[http://www.php-fig.org/psr/psr-4/|PSR-4 (Autoloader)]] to ensure a high level of interoperability between shared PHP code. The package requires PHP 5.4+ and comes bundled with a Laravel 5 Facade and a Service Provider to simplify the optional framework integration. * [[https://github.com/srlabs/centaur|Centaur]]provides an opinionated implementation of Cartalyst Sentinel for Laravel. * [[https://naomiaro.com/2015/07/22/password-reminders-with-sentinel-and-laravel/|Password Reminders with Sentinel and Laravel]], [[https://naomiaro.com/2015/07/17/changing-a-users-password-with-sentinel-and-laravel/|Changing a User’s Password with Sentinel and Laravel]] ===== Route ===== ==== Implicit Model Binding ==== [[http://blog.laravel.com/laravel-5-release-dates/|Laravel 5.2]]: Implicit Model Binding use AppUser; Route::get('/user/{user}', function (User $user) { return $user; }); ==== REST API ==== Simple but usefull [[https://gist.github.com/beanmoss/977e846fee4050ae11e5|RestControllerTrait]] Dingo https://github.com/dingo/api/ * A RESTful API package for the Laravel and Lumen frameworks. JWT-auth provides a simple means of authentication within Laravel using JSON Web Tokens * https://github.com/tymondesigns/jwt-auth ===== Views ===== ==== Laravel Mix ==== Laravel Mix provides a fluent API for defining Webpack build steps for your Laravel application using several common CSS and JavaScript pre-processors. * [[https://www.larashout.com/laravel-mix|Laravel Mix – The Complete Guide]] * [[https://scotch.io/tutorials/using-laravel-mix-with-webpack-for-all-your-assets|Using Laravel Mix with webpack for All Your Assets]] ==== Components ==== [[https://laravelcollective.com|Laravel Collective]] * [[https://laravelcollective.com/docs/5.3/html|Forms & HTML]] * [[https://github.com/StydeNet/html|StydeNet]] is an extension to the Laravel Collective HTML package. * Menus, Alert messages, Form fields, Collection of radios and checkboxes ==== Component Pull ==== La documentation [[https://laravel.com/docs/5.2/views#view-composers|View Composers]] présente l'insertion automatique de données dans des vues que je vois comme du "Component Push". Ça manque d'exemple, notamment le paradigm du "Component Pull" : Exprimer l'insertion d'un composant depuis une vue. Appeler le "composant" depuis une vue Blade: @inject('navstage', 'NavStage') {{ echo $navstage->render() }}. L'appel ''@inject()'' demande au "Service Container" de trouver l'instance d'un objet référencé sous le nom ''NavStage''. Il faut donc que cet objet ai été créer et référencé: // dans App/Providers/AppServiceProvider.php public function boot() { $this->app->singleton('NavStage', function ($app) { return new \App\Services\NavStage(); }); } Il faut bien sûr qu'existe la classe ''\App\Services\NavStage'' avec une méthode ''render()'' (cf. la vue Blade). **Nota bene**: l'appel ''%%{{ $navstage→render() }}%%'' n'imprime pas le résultat de l'appel à ''render()'', il faut donc faire un ''echo'' dans la méthode. **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 ==== [[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 '''' 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 ==== CKeditor laravel package: * https://packagist.org/packages/unisharp/laravel-ckeditor Laravel file manager (for CKEditor and TinyMCE) with multi-users support * https://github.com/UniSharp/laravel-filemanager ==== VUE.js ==== //voir [[/informatique/javascript#vuejs|Vue.js]]// * [[https://medium.com/laravel-news/advanced-front-end-setup-with-vue-js-laravel-e9fbd7e89fe2|Laravel and Vue.JS: Advanced Frontend Webapp Architecture]] * Simple guestbook example [[https://github.com/laracasts/Laravel-and-Vue/]] Since many JavaScript frameworks also use "curly" braces to indicate a given expression should be displayed in the browser, you may use the @ symbol to inform the Blade ... [[https://laravel.com/docs/5.3/blade#blade-and-javascript-frameworks|Blade & JavaScript Frameworks]] ==== Divers ==== * Menu: The [[https://docs.spatie.be/menu|spatie/menu]] package provides a fluent interface to build menus of any size in your php application. If you're building your app with Laravel, the spatie/laravel-menu provides some extra treats. ===== Localization ===== Messages de validation en 52 langues pour Laravel4/5: https://github.com/caouecs/Laravel-lang Manage translation in database: * **[[https://github.com/hpolthof/laravel-translations-db|hpolthof/laravel-translations-db]]** a Laravel translations from Database; * store translations in the database and default load from files, cache translation, comes with a crud-interface and can perform translations via Google Translate. * [[https://github.com/Waavi/translation|waavi/translation]] translation management for Laravel with files, database and cache. * **[[https://github.com/spatie/laravel-translation-loader|spatie/laravel-translation-loader]]** offers a driver based way to store and retrieve translations and ships with a default driver that stores translations in the db. Manage translation files: * [[https://github.com/barryvdh/laravel-translation-manager|barryvdh/laravel-translation-manager]] is a package to manage Laravel translation files. It does not replace the Translation system, only import/export the php files to a database and make them editable through a webinterface. Translation in Eloquent ORM * [[https://laravel-news.com/2015/09/how-to-add-multilingual-support-to-eloquent/|How To Add Multilingual Support to Eloquent]] * A Laravel package for multilingual models [[https://github.com/dimsav/laravel-translatable|dimsav/laravel-translatable]] ===== Tests & Testing ===== * [[https://laravel-news.com/2015/10/learn-to-use-model-factories-in-laravel-5-1/|Learn to use Model Factories in Laravel 5.1]] ===== Others ===== * [[http://laravelcollective.com/docs/5.0/ssh|Remote SSH]] ==== Command ==== $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) ==== Cache ==== === Cache Lock === Cache Lock appears with [[https://laravel.com/docs/5.5/releases|Laravel 5.5]], only for Redis et Memcached cache driver. It's not in the [[https://laravel.com/docs/5.5/releases|cache documentation]] but in [[https://laravel.com/docs/5.5/releases#laravel-5.5|Release documentation]]. try { $lock = Cache::lock('foo', 10)->block(5); // Lock acquired after waiting maximum of 5 seconds... } catch (LockTimeoutException $e) { // Unable to acquire lock... } finally { optional($lock)->release(); } Qlqs articles : * [[https://laravel.io/articles/preventing-duplicate-form-submissions-using-atomic-locks|Preventing Duplicate Form Submissions Using Atomic Locks]] * [[https://wpwebinfotech.com/blog/atomic-locks-in-laravel/|Atomic Locks in Laravel: Mastering Concurrency and Data Integrity]] * [[https://dev.to/afiqiqmal/preventing-duplicate-requests-in-laravel-the-atomiclockmiddleware-j46|Preventing Duplicate Requests in Laravel: The AtomicLockMiddleware]] ==== Security ==== === Throttle === Le middleware [[https://github.com/laravel/framework/blob/5.2/src/Illuminate/Routing/Middleware/ThrottleRequests.php|Illuminate\Routing\Middleware\ThrottleRequests]] retourne un code [[https://fr.wikipedia.org/wiki/Liste_des_codes_HTTP#Erreur_du_client_.2F_du_serveur_web|HTTP 429]] quand le nombre de requêtes dans un nombre de minutes est dépassé. Il utilise le cache [[https://github.com/laravel/framework/blob/5.2/src/Illuminate/Cache/RateLimiter.php|Illuminate\Cache\RateLimiter]]. Pour identifier le client il utilise la méthode ''fingerprint()'' de [[https://github.com/laravel/framework/blob/5.2/src/Illuminate/Http/Request.php|Illuminate\Http\Request]]. \\ Malheureusement cette méthode ''fingerprint()'' n'**utilise que l'IP** comme données du client.\\ Bien qu'il soit impossible de calculer une empreinte sure, j'ai demandé l'ajout du remote port [[https://github.com/laravel/framework/issues/12872|#12872]]. === Laravel cookie forgery === Ce bug n'est-il pas réapparu ? Un test unitaire existe-t-il ? [[https://labs.mwrinfosecurity.com/blog/laravel-cookie-forgery-decryption-and-rce/|Laravel cookie forgery, decryption, and RCE]] MWR, 11 April 2014 ==== Infrastructure & serveur ==== * [[http://laravel-recipes.com/recipes/26/creating-a-nginx-virtualhost|Creating a Nginx VirtualHost]] * [[https://murze.be/2017/01/varnish-on-a-laravel-forge-server/|Using Varnish on a Laravel Forge provisioned server]] To make default prefixed route working, like ''/admin'' or ''/foo'', while a folder with the same name exists, like ''public/admin'' or ''public/foo'', should remove the $uri/ from nginx rewriting: replace location / { try_files $uri $uri/ /index.php?$query_string ; } by location / { try_files $uri /index.php?$query_string ; } ==== Error catcher ==== [[/informatique:error_services|informatique/error_services]] Avec [[https://sentry.io|Sentry.io]] : * [[https://sentry.io/for/laravel/|https://sentry.io/for/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]] /** * @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) */ ==== Wordpress and Laravel ==== * https://laravel-news.com/2016/01/wordpress-and-laravel/ * [[http://laraveldaily.com/holywar-when-to-use-laravel-vs-wordpress/|Holywar: when to use Laravel vs WordPress?]] ==== Charts & graphs ==== * [[https://github.com/ConsoleTVs/Charts|Charts]] is a multi-library chart package to create interactive charts using laravel (chartjs, highcharts, material, morris ...). ==== Package development ==== * How to compile assets (Javascript, css, ...) in package folder (at package dev time) ? * https://laracasts.com/discuss/channels/tips/package-development-workflow-1 ==== Wordpress and Laravel ==== * [[https://laravel-news.com/2016/01/wordpress-and-laravel/|https://laravel-news.com/2016/01/wordpress-and-laravel/]] * [[http://laraveldaily.com/holywar-when-to-use-laravel-vs-wordpress/|Holywar: when to use Laravel vs WordPress?]] ==== Charts & graphs ==== * [[https://github.com/ConsoleTVs/Charts|Charts]] is a multi-library chart package to create interactive charts using laravel (chartjs, highcharts, material, morris …). ==== Tools ==== * [[https://madewithlaravel.com/laravel-top|laravel-top]] un ''top'' pour Laravel (request, memory, cache, database) * [[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-ide-helper|Laravel 5 IDE Helper Generator]] generates correct PHPDocs for all Facade classes, to improve auto-completion. * A docker compose for Laravel (example) : [[https://github.com/edbizarro/ambientum|https://github.com/edbizarro/ambientum]] [[https://beyondco.de/blog/the-ultimate-guide-to-php-artisan-tinker|tinker and tinkerWell]] ==== Queue and MQ ==== {{ :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 === * [[https://divinglaravel.com/queue-workers-how-they-work|Queue Workers: How they work]] explain the full stack of laravel queue, event, worker and process * [[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 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]]. === RabbitMQ === [[:informatique:rabbitmq|RabbitMQ]] Posts: * question [[https://laracasts.com/discuss/channels/laravel/multiple-rabbitmq-queues|Multiple RabbitMQ Queues?]] (2015) * [[https://victorcruz.me/rabbitmq-client-for-laravel/|Tail: RabbitMQ client for Laravel]] (2015) with lib mookofe/tail * [[https://stackoverflow.com/questions/33946819/get-total-number-of-queued-jobs-laravel-rabbitmq|get total number of queued jobs laravel — RabbitMQ]] : Rrabbit MQ HTTP API, Libs: * [[https://github.com/vyuldashev/laravel-queue-rabbitmq|vyuldashev/laravel-queue-rabbitmq]] (2017-11→2018-01, 24 contributors) * RabbitMQ driver for Laravel Queue * [[https://github.com/php-enqueue/laravel-queue|php-enqueue/laravel-queue]] (2017-07→2017-12, 2 contributors) * Laravel Enqueue message queue extension. * Supports AMQP, Amazon SQS, Kafka, Google PubSub, Redis, STOMP, Gearman, Beanstalk and others * [[https://enqueue.forma-pro.com/|https://enqueue.forma-pro.com/]] * [[https://github.com/shaobaojie/laravel_rabbit_mq|shaobaojie/laravel_rabbit_mq]] (updated 2016-07) * RabbitMQ Queue driver for Laravel * [[https://github.com/mookofe/tail|mookofe/tail]] (2015-03→2016-07, 2 contributors) * RabbitMQ and PHP client for Laravel that allows you to add and listen queues messages just simple. * Simple queue configuration * Multiple server connections * Add message to queues easily * Listen queues with useful options * require videlalvaro/php-amqplib: 2.* * [[https://github.com/bschmitt/laravel-amqp|bschmitt/laravel-amqp]] (2016-01→2017-10, 7 contributors) * AMQP wrapper for Laravel and Lumen to publish and consume messages * Advanced queue configuration * Add message to queues easily * Listen queues with useful options * methods: Amqp::publish(), Amqp::consume() * Some concepts were used from [[https://github.com/mookofe/tail|mookofe/tail]]