Contents
CodeIgniter
A lightweight framework with a simple structure: routes, controllers, models and minimal configuration.
1.Getting started
- Meet CodeIgniterWhat CodeIgniter 4 is, how to create a project, which folders it contains and how to see the first page.
- The spark console toolWhat spark is in CodeIgniter: starting the server, the command list, help and the make commands that create files.
- RoutingCodeIgniter routes: the app/Config/Routes.php file, HTTP methods, parameters in the address, route names, groups and the url_to function.
- ControllersCodeIgniter controllers: the app/Controllers folder, the make:controller command, action methods, parameters from the address and the BaseController class.
- Requests and responsesHow a CodeIgniter controller reads address parameters and form fields and returns a response: text, a redirect or JSON.
- ViewsCodeIgniter views: the app/Views folder, the view function, passing data from a controller, escaping with esc, conditions and loops.
- Layouts, sections and partialsLayouts in CodeIgniter: a shared page frame, the extend, section and renderSection methods, and including view partials with include.
- HelpersCodeIgniter helpers: the helper function, the url helper for addresses and links, automatic loading and your own file in app/Helpers.
- Configuration and the .env fileCodeIgniter configuration: classes in app/Config, the config function, your own config file, overriding values in .env and environments.
2.Database
- Database connectionHow to connect CodeIgniter to MySQL: the database settings in the .env file, the db:create command and checking the connection from a controller.
- MigrationsMigrations in CodeIgniter: the make:migration command, describing a table with Forge, running, rolling back and changing the table structure.
- SeedersSeeders in CodeIgniter: the make:seeder command, filling a table with initial data, running with db:seed and calling several seeders.
- ModelsCodeIgniter models: the make:model command, the allowedFields property, reading records with find and findAll, saving with save and deleting.
- The Query BuilderThe Query Builder in CodeIgniter: selecting with conditions, sorting, joining tables, inserting and updating rows, SQL queries with parameters.
- EntitiesEntities in CodeIgniter: the make:entity command, objects instead of arrays, type casting, dates and your own methods on a record.
- PaginationPagination in CodeIgniter: the model's paginate method, the pager object, page links in a view and the settings in app/Config/Pager.php.
3.Application
- ValidationValidation in CodeIgniter: rules in a controller, the validateData and validate methods, the list of rules, custom messages and rule groups.
- FormsForms in CodeIgniter: the form helper, a page with a form and its handler, CSRF protection, showing validation errors and the old function.
- Sessions and flash dataSessions in CodeIgniter: the session function, writing and reading values, flash messages after a redirect and the settings in app/Config/Session.php.
- FiltersFilters in CodeIgniter: the make:filter command, the before and after methods, registration in app/Config/Filters.php and attaching to routes and groups.
- Logging inAuthentication in CodeIgniter: the users table, the password hash, a login and logout controller built on the session and the official Shield package.
- File uploadsFile uploads in CodeIgniter: a form with a file, the getFile method, the uploaded, is_image and max_size rules, saving under a safe name.
4.Growing the project
- A REST APIAn API on CodeIgniter: the ResourceController class, resource routes, the respond and fail methods, receiving JSON and ResponseTrait in an ordinary controller.
- CachingThe cache in CodeIgniter: the cache function, the save, get, remember and delete methods, caching a whole page and the settings in app/Config/Cache.php.
- Sending emailEmail in CodeIgniter: SMTP settings in .env and app/Config/Email.php, the email service, a message from a view, attachments and checking delivery.
- Custom spark commandsYour own spark commands in CodeIgniter: make:command, the BaseCommand class, arguments and options, terminal output and running on a schedule.
- Logging and error pagesLogging in CodeIgniter: the log_message function, levels and the writable/logs folder, the threshold in app/Config/Logger.php and custom 404 and 500 pages.
- Testing basicsTests in CodeIgniter: the tests folder, running PHPUnit, the CIUnitTestCase class, checking pages with FeatureTestTrait and tests with a database.
- DeploymentHow to deploy a CodeIgniter project to a server: the public folder as the site root, the .env file, permissions on writable, migrations and the optimize command.