Contents
Laravel
The most popular PHP framework: routes, controllers, Blade templates and database access.
1.Getting started
- What is LaravelWhy the Laravel framework exists and how to create your first project.
- RoutingHow to connect a page address to code: routes, parameters and names.
- ControllersHow to move request handling out of the routes file into controller classes.
- Blade templatesHow to render HTML pages: templates, variables, conditions, loops and a shared layout.
- Requests and responsesThe Request object in Laravel, reading request data, and the kinds of responses: a template, JSON, a redirect and a file.
- Blade componentsComponents in Laravel templates: your own tags, attributes, slots and a page layout built from components.
2.Database
- MigrationsHow to describe database tables in code and change their structure.
- Eloquent modelsWorking with tables through model classes: reading, creating, updating and deleting records.
- Model relationshipsOne-to-many and many-to-many: how to get related records.
- The query builderDatabase queries in Laravel: where conditions, sorting, selecting columns, aggregates and joining tables.
- More EloquentQuery scopes, attribute casting, computed properties, soft deletes and model events in Laravel.
- CollectionsLaravel collections: transforming, filtering, grouping and totalling query results and plain arrays.
- PaginationPagination in Laravel: the paginate method, page links in a template, keeping filters and processing large tables in chunks.
- Polymorphic relationshipsPolymorphic relationships in Eloquent: one comments table for posts and videos, morphTo and morphMany, tags with morphToMany and the morph map.
- Model events and observersEloquent events: creating, updated, deleting and others, handlers in the booted method, observer classes and saving without events.
- Transactions and query speedEloquent performance: the N+1 problem, withCount, forbidding lazy loading, processing large tables in chunks, transactions and indexes.
3.Building an app
- Forms and validationHow to accept form data, validate it and show errors to the user.
- MiddlewareCode that runs before or after a request is handled.
- AuthenticationRegistering, logging in and logging out a user, protecting pages from guests.
- Form requestsForm Request in Laravel: moving validation rules out of the controller, checking permissions, custom error messages and preparing data.
- AuthorizationAuthorization in Laravel: gates and policies, checking permissions in a controller, a template and a route.
- Sessions and cacheSessions and cache in Laravel: keeping user data between requests, flash messages and caching slow queries.
4.Growing the app
- Factories and seedersHow to fill the database with test data in Laravel: model factories, seeders and the db:seed command.
- APIHow to build a JSON API in Laravel: api.php routes, resource controllers, API resources and response codes.
- Uploading and storing filesWorking with files in Laravel: accepting an uploaded file, disks, the public link and deleting.
- TestingAutomated tests in Laravel: checking pages and the database, acting as a user and running the tests.
- Deploying to a serverHow to put a Laravel app on a production server: requirements, .env settings, optimisation commands and updating.
- Calling other servicesLaravel's HTTP client: the Http facade, GET and POST requests, headers and tokens, timeouts, retries, error handling and faking in tests.
- Helpers: strings, arrays, datesLaravel's helper functions: the Str class and str() chains, Arr and data_get, Carbon dates, Number formatting and debugging.
- API tokens and rate limitingLaravel Sanctum: issuing a token on login, protecting routes with auth:sanctum, token abilities, revoking and rate limiting.
- Tests: factories, fakes and PestDeeper testing in Laravel: model factories and states, faking mail, queues, files and HTTP, the Pest syntax and parallel runs.
5.Background work
- Queues and jobsQueues in Laravel: moving slow operations into background jobs, running the worker and retrying.
- Mail and notificationsSending email in Laravel: Mailable classes, the message template, sending through a queue and multi-channel notifications.
- EventsEvents and listeners in Laravel: how to separate the main action from side effects and run listeners in a queue.
- Task schedulingScheduled tasks in Laravel: describing the schedule in code, run frequency and a single cron entry on the server.
6.Framework internals
- The container and providersLaravel's service container: dependency injection, binding interfaces to implementations, providers and facades.
- Custom Artisan commandsYour own console commands in Laravel: arguments and options, terminal output, asking the user questions and running on a schedule.
- Configuration and localisationLaravel configuration: the .env file and the config function, your own settings, translation files and switching the site language.
- Logging and error handlingLogging and errors in Laravel: the Log facade, message levels, channels, custom error pages and exception handling.
- Styles and scriptsThe front end in Laravel: the Vite bundler, adding CSS and JavaScript to a template, Tailwind CSS and building for production.
- Livewire: interactivity without JavaScriptLaravel Livewire: a component made of a class and a template, wire:click and wire:model, live search, validated forms and property safety.