Laravel est un framework PHP open-source qui facilite le développement d'applications web robustes et élégantes. Il suit le modèle MVC (Modèle-Vue-Contrôleur) et est conçu pour rendre le développement web plus accessible, en fournissant une syntaxe expressive et des fonctionnalités int�...
Laravel est un framework PHP open-source qui facilite le développement d'applications web robustes et élégantes. Il suit le modèle MVC (Modèle-Vue-Contrôleur) et est conçu pour rendre le développement web plus accessible, en fournissant une syntaxe expressive et des fonctionnalités intégrées.
Caractéristiques Principales
Architecture MVC : Sépare la logique de l'application de l'interface utilisateur, ce qui facilite la gestion du code.
ORM Eloquent : Laravel propose un système de mappage objet-relationnel (ORM) qui simplifie les interactions avec les bases de données.
Routing Avancé : La gestion des routes est simple et flexible, permettant de définir des routes RESTful facilement.
Middleware : Permet d'intercepter les requêtes HTTP et de gérer des actions comme l'authentification et la validation.
Tests Automatisés : Laravel facilite l'écriture de tests automatisés pour garantir la fiabilité de l'application.
Tâches Programmées : Le planificateur de tâches intégré permet d'automatiser les tâches régulières.
Size: 31.04 MB
Language: en
Added: Oct 20, 2024
Slides: 178 pages
Slide Content
Laravel 10 Developpement back-end Pr. Y.abouqora
Laravel 01 Démarrer un projet laravel
Plan Jour 1 Créer un projet Laravel Travailler avec la base de données. Travailler avec le modèle Travailler avec les contrôleurs Travailler avec les vues Ce qu'il faut : Laragon phpMyAdmin VS Code 3
Create Laravel First Project Installez Laravel en lançant la commande Composer create-project dans votre terminal 5 composer create-project – prefer-dist laravel / laravel project - name
With Laragon ? Never been EASIER. laragon.org
Laragon Qu'est-ce que Laragon ? Laragon est un environnement de développement universel portable, isolé, rapide et puissant pour PHP, Node.js, Python, Java, Go, Ruby. Il est rapide, léger, facile à utiliser et à étendre. Pourquoi Laragon ? Laragon est idéal pour construire et gérer des applications web modernes. Il est axé sur la performance - conçu autour de la stabilité, de la simplicité, de la flexibilité et de la liberté. Laragon améliore le développement web. Les développeurs du monde entier utilisent Laragon pour créer des applications rapidement et facilement. Il est utilisé par des milliers de développeurs avec amour. Vous pouvez consulter les témoignages pour voir ce que les utilisateurs pensent de Laragon et la page des caractéristiques pour plus de détails. 7
Change DB root password 8
Laravel t02 Comment ajouter facilement une page de connexion et une liste d'utilisateurs ?
Turn On Laragon Par défaut, Laragon utilise le port 80 pour Apache et le port 3306 pour la base de données. 10
Create Project 11
Laravel project with Pretty URL Test the Pretty url in browser 12
Modifier DB credentials in .env 13
Download and install phpmyadmin.Net Essayez l'accès http://localhost/ pma 14
Phpmyadmin config.inc 15
Authentication Module Laravel rend la mise en œuvre de l'authentification très simple. En fait, presque tout est configuré pour vous dès le départ. 16 composer require laravel / ui --dev php artisan ui bootstrap -- auth npm install & npm run dev
Authentication Module 17
18
Laravel t03 Base de données– migration, seeder & factory
Working with Database Migrations de bases de données Les migrations sont comme un contrôle de version pour votre base de données. 22 public function up() { Schema :: create ('trainings', function ( Blueprint $table) { $ table bigIncrements ('id’); $ table string (' title ’); $ table text ('description’); $ table string ('trainer’); $ table timestamps (); $ table unsignedBigInteger (' user_id ’); $ table foreign (' user_id ')—> references ('id')—>on(' users '); }); Make Migrations php artisan make:migration create_trainings_table
php artisan migrate 23 Run Migrations php artisan migrate
Model Models typically live in the app directory. All Eloquent models extend Illuminate\Database\Eloquent\Model class. 24
Model Model also can be used to to specify custom table. Model also can be used to define mutator Model also can be used to define local scope Model used to define fillable attributes. Model also can be used to define relationship 25
Working with Database Database Seeds Laravel includes a simple method of seeding your database with test data using seed classes. On database / seeds / DatabaseSeeder.php On database / seeds / TrainingsTableSeeder.php 26
Working with Database : run seeder 27
Working with Database Database Factories Laravel has a feature called model factories that allows you to build fake data for your models. 28
How to create and run migrations, seeder and factory? Here are the example. 29
Laravel t04 Views (create form, save new record, list records in index )
Views Views contain the HTML served by your application and separate your controller / application logic from your presentation logic. Views are stored in the resources/views directory Go to resources/views Create training folder Inside training folder, create: create.blade.php index.blade.php 34
Views – Create View Views are stored in the resources/views directory Go to resources/views/trainings/ create.blade.php 35
Views – Index View Views are stored in the resources/views directory Go to resources/views/trainings/ index.blade.php 36
Controller Instead of defining all of your request handling logic as Closures in route files, you may wish to organize this behavior using Controller classes. Controllers can group related request handling logic into a single class. Controllers are stored in the app/Http/Controllers directory. 39
Routing All Laravel routes are defined in your route files, which are located in the routes directory. https://laravel.com/docs/6.x/routing . 46
Simple Routing All Laravel routes are defined in your route files, which are located in the routes directory. https://laravel.com/docs/6.x/routing . 47
Search – Index Method Check if there is keyword, if there is keyword on query string, run query to search column where like title. If no keyword, the method will return collection rows from trainings table. 59
Laravel t08 Pagination
61
Search - Pagination The paginate method automatically takes care of setting the proper limit and offset based on the current page being viewed by the user and append with keywords. 62
TrainingController@index 63
Hacks Creating Index - https://github.com/samtarmizi/laravel-spr/commit/1c925853f61da081f0e3ce298e58a4a423b66040 Creating Create - https://github.com/samtarmizi/laravel-spr/commit/7a5b5f3b643bcb8a265af3bb9f4e94e3aef95aa1 Creating Store - https://github.com/samtarmizi/laravel-spr/commit/2513b55c65bc4d27afa5004144ee2c7d41b3cbd7 64
Laravel t10 npm not found
npm not found http://fstm.kuis.edu.my/blog/laravel 66
Authentication Module Laravel makes implementing authentication very simple. In fact, almost everything is configured for you out of the box. 67
Laragon Includes NODEJS http://fstm.kuis.edu.my/blog/laravel 68
Terminal in Laragon Laravel makes implementing authentication very simple. In fact, almost everything is configured for you out of the box. http://fstm.kuis.edu.my/blog/laravel 69
Locate nodejs in Laragon http://fstm.kuis.edu.my/blog/laravel 70
Middleware Middleware provide a convenient mechanism for filtering HTTP requests entering your application. For example, Laravel includes a middleware that verifies the user of your application is authenticated. If the user is not authenticated, the middleware will redirect the user to the login screen. http://fstm.kuis.edu.my/blog/laravel 75
DISCLAIMER Codes are for demo purposes. Example showed here are only to validate the proof of concepts. Security aspect the demonstrated examples are beyond the coverage of these video tutorials. You are advised to explore / sought after advanced/security topics of PHP web programming as these tutorials only for beginner level. Suitable to view in DESKTOP 10/20/2024 fstm.kuis.edu.my 87
Views Views are stored in the resources/views directory Go to resources/views Go to trainings folder, create: show.blade.php edit.blade.php http://fstm.kuis.edu.my/blog/laravel 88
Controller 7 method in controllers http://fstm.kuis.edu.my/blog/laravel 89
Controller - Show http://fstm.kuis.edu.my/blog/laravel 91
Views – Show View Views are stored in the resources/views directory Go to resources/views/trainings/show.blade.php http://fstm.kuis.edu.my/blog/laravel 92
CDN – CONTENT DELIVERY NETWORK CDN – load library/ framework from public host server t o provide high availability and performance https://www.bootstrapcdn.com/fontawesome/ 97
FONTAWESOME IN SIMPLE HTML http://fstm.kuis.edu.my/blog/laravel 98
Import font-awesome from CDN http://fstm.kuis.edu.my/blog/laravel 99
Tag: <i></i> <i class="fa fa-file-text"></i> <p>Used on a button:</p> <button> Show <i class="fa fa-file-text"></i> </button> 100
Implement in buttons http://fstm.kuis.edu.my/blog/laravel 103
Github.com/khirulnizam/lara7 Slides & codes 104
Laravel t15 Edit/Update
UPDATE RECORD PROCESS 10/20/2024 106 Index (choose ) id id Edit (form) Update (save)
DISCLAIMER Codes are for demo purposes. Example showed here are only to validate the proof of concepts. Security aspect the demonstrated examples are beyond the coverage of these video tutorials. You are advised to explore / sought after advanced/security topics of PHP web programming as these tutorials only for beginner level. Suitable to view in DESKTOP 10/20/2024 107
DISCLAIMER Codes are for demo purposes. Example showed here are only to validate the proof of concepts. Security aspect the demonstrated examples are beyond the coverage of these video tutorials. You are advised to explore / sought after advanced/security topics of PHP web programming as these tutorials only for beginner level. Suitable to view in DESKTOP 10/20/2024 115
Delete button inside FORM http://fstm.kuis.edu.my/blog/laravel 118
Routing – Group and Named Route All Laravel routes are defined in your route files, which are located in the routes directory. https://laravel.com/docs/7.x/routing. 119
Routing – Group and Named Route php artisan route:list https://laravel.com/docs/7.x/routing . 120
Controller – Destroy/Delete 121
Laravel t17 @csrf (Built-in security token for post method)
DISCLAIMER Codes are for demo purposes. Example showed here are only to validate the proof of concepts. Security aspect the demonstrated examples are beyond the coverage of these video tutorials. You are advised to explore / sought after advanced/security topics of PHP web programming as these tutorials only for beginner level. Suitable to view in DESKTOP 10/20/2024 123
What is CSRF? 125 OWASP.org Cross-Site Request Forgery - is an attack that forces an end user to execute unwanted actions on a web application in which they're currently authenticated.
Implementation in Laravel blade 126
Location of csrf app_key Use to hash security token http://fstm.kuis.edu.my/blog/laravel 127
DISCLAIMER Codes are for demo purposes. Example showed here are only to validate the proof of concepts. Security aspect the demonstrated examples are beyond the coverage of these video tutorials. You are advised to explore / sought after advanced/security topics of PHP web programming as these tutorials only for beginner level. Suitable to view in DESKTOP 10/20/2024 130
DISCLAIMER Codes are for demo purposes. Example showed here are only to validate the proof of concepts. Security aspect the demonstrated examples are beyond the coverage of these video tutorials. You are advised to explore / sought after advanced/security topics of PHP web programming as these tutorials only for beginner level. Suitable to view in DESKTOP 10/20/2024 143
DISCLAIMER Codes are for demo purposes. Example showed here are only to validate the proof of concepts. Security aspect the demonstrated examples are beyond the coverage of these video tutorials. You are advised to explore / sought after advanced/security topics of PHP web programming as these tutorials only for beginner level. Suitable to view in DESKTOP 10/20/2024 156
Storage not found http://fstm.kuis.edu.my/blog/laravel 169
Configuring Filesystem for Storage config/filesystems.php 170
File Storage Create Symbolic Link The public disk is intended for files that are going to be publicly accessible. By default, the public disk uses the local driver and stores these files in storage/app/public. To make them accessible from the web, you should create a symbolic link from public/storage to storage/app/public . 171
Virtual link of public file storage 172
Physical link of public file storage http://fstm.kuis.edu.my/blog/laravel 173 The actual physical location of the file storage To make them accessible from the web, you should create a symbolic link from public/storage to storage/app/public .