Description
In this course, you will learn :
- Local installation and configuration of CodeIgniter.
- What distinguishes an MVC framework like CodeIgniter from "plain" PHP.
- Database records can be created, read, updated, and deleted (CRUD).
- User registration by email, followed by account activation.
- Login with remember me, and access to content requires login.
- Email password reset initiated by the user.
- Images are being uploaded and processed.
- Ajax requests are handled and JSON is returned.
- Using a CSS framework for styling.
- Internationalisation refers to the display of content in more than one language.
- Deploying an application to shared hosting in a secure manner.
- Direct instructor assistance: any question asked in the Q&A section will always receive a response.
Syllabus :
1. Introduction and project setup
- Introduction and welcome: how to get the most out of the course
- Install a web server with PHP, database server and phpMyAdmin
- Create an empty database in the local database server
- Install the CodeIgniter framework, optionally using Composer
- Configure the framework to display error messages
- Configure the web server to access the framework using a virtual host
- Common installation / configuration issues and their solutions
2. CodeIgniter and MVC basics: controllers, views and layouts
- MVC basics: how a framework is different to plain PHP
- View basics: create and display the homepage
- Routing: how CodeIgniter decides which controller and method to run
- Add another controller and view to display a list of tasks
- Showing multiple views: two techniques for reducing code repetition
- View layouts: use a base layout for common view code
- Add a section for the title and use the layout in the task index
3. Database data: models, configuration and migrations
- Displaying dynamic data: pass data from a controller to a view
- Configure the framework to connect to the database
- Database migrations: create the task table in the database
- Migrations without the command line: add columns using a controller
- Models: connect to the database and select data automatically
- Debugging tools: enable the debug bar and use the dd function
4. CRUD Part 1: Displaying and inserting new data
- Add a page to show an individual record
- Add links between pages using the site_url helper
- Create and display a form for adding a new task using the form helper
- Add a method to process the submitted form and insert a new record
- Add validation rules and validate the form
- Redirect to the show page if validation passes or redisplay the form if not
- Flash messages: add status messages to the result of processing the form
- Prevent XSS attacks by escaping untrusted data
5. CRUD Part 2: Editing and deleting existing records
- Add a form to edit an existing task and link to it from the show page
- Add a method to process the submitted form and update the record
- Show the previously-entered values in the form when redisplaying it
- Extract shared form code out into a shared view
- Addendum: change to the base CodeIgniter Entity class namespace
- Entity classes: use an object to represent a database row instead of an array
- Change the create method to use the Task entity class
- Change the update method to use the Task entity class
- Extract common controller code out to the constructor
- Show a 404 not found page if the task ID isn't found
- Enable automatic updating of the created_at and updated_at fields
- Add a page with a confirmation message for deleting a task record
6. Signup: User account registration
- Add and run a migration to create the user table
- Add a signup controller and display the signup form
- Add a create method and insert a new user record
- Use a model event to hash the password when a new record is inserted
- Validate the data in the signup form and redisplay it if invalid
- Display a signup success page on valid signup
7. Authentication: login, logout and user identification
- Create a login controller and show the login form
- Verify the email and password against the user records in the database
- Log in the authenticated user using the session
- Log out the user when the browser closes and also with a logout action
- Add a helper to show the current user name
- Create and use a class for all the authentication code
- Add a method to get the current user
- Access the authentication object using a service
- Simplify the authentication class: extract code out to the user model and entity
- Avoid multiple identical database queries by caching the user record
8. Protecting content: require the user to login to access certain content
- Require the user to login to access the tasks index page
- Controller filters: require login for all the methods in the tasks controller
- Apply a filter to certain routes to require the user not to be logged in
- Move links to the default layout for consistent navigation
- Redirect to the originally requested page after logging in
- Protect against cross-site request forgery attacks with the CSRF filter
9. Link the tasks to users and paginate the task index
- Add a foreign key from the task table to the id column in the user table
- Show only the tasks for the current user in the task index
- Select individual task records for the current user only
- Assign the id of the current user when creating a new task record
- Get the current user in the task controller constructor
- Display the list of tasks in chronological order
- Paginate the list of tasks
10. User administration: user CRUD
- Create a users controller in its own namespace
- Show a paginated list of user records
- Show an individual user record
- Insert a new user record
- Display the form for editing an existing user record
- Update a user record with conditional password validation
- Add password help text to the form when editing a user
- Delete a user record with confirmation
11. User administration: restrict access to administrator users
- Require login to access the user admin controller
- Add a column to the user table to identify admin users
- Add a seeder to insert an admin user
- Require an admin user to access the user admin controller
- Display a navigation link to the users index and user admin status
- Prevent an admin user from deleting their own account while logged in
- Add an is_admin checkbox to the form for creating or editing a user
- Enable removal of admin privileges when editing an existing admin user
- Prevent an admin user from removing admin access while logged in
12. Account activation by email
- Account activation: confirm the user's email address exists
- Add columns to the user table for account activation
- Generate a random activation token and its keyed hash
- Store the activation hash in the database when a user signs up
- Prevent inactive accounts from logging in
- Send an email using the CodeIgniter email library
- Send an activation email containing the token to the user when they sign up
- Activate the account when the user clicks on the link in the email
- Add the active status to the user admin section
- Instantly log a user out by making their account inactive
13. User-initiated password reset
- Add a controller and view for starting the password reset process
- Add a migration to add password reset columns to the user table
- Create a class to generate random tokens and their hashes
- Process the password reset form and generate a random reset token and expiry
- Send the password reset email to the user
- Display the password reset form, checking the token and its expiry
- Process the password reset form and reset the user's password
14. User profile: allow a user to change their own data
- Add a profile controller and restrict access to authenticated users only
- Add a form to edit the current user's details
- Validate and update the profile data
- Add a form for changing the current user's password
- Change the current user's password
- Require the user to enter their password to make changes to their profile
15. Handling file uploads and images: user profile image
- Add a column to the user table for the profile image
- Add a controller with an edit method for uploading an image file
- Validate the uploaded file
- Restrict the file upload by size and type
- Store the uploaded file in its permanent location
- Resize and crop the uploaded image
- Save the name of the uploaded file to the user record
- Display a blank image for those users without a profile image
- Display the user's uploaded profile image in the show profile page
- Add an option to delete the profile image
16. Remember me: remembering the login between browser sessions
- Remembering the login between browser sessions
- Add a migration to store the remember tokens in the database
- Add a remember me checkbox to the login form and get its value in the controller
- Generate a random remember me token and save its hash in the database
- Set a cookie containing the remember me token
- Refactor the authentication class
- Log in automatically using the token in the cookie
- Delete the cookie and the remembered token in the database
- Add a custom console command to clean up expired remembered login records
17. Ajax requests and JSON: searching for tasks
- Addendum to "Add a JavaScript autocomplete library"
- Add a JavaScript autocomplete library
- Search for tasks by matching the description to the search term
- Return JSON from the search method
- Add a search input and make an Ajax request to the search URL
- Use the autocomplete library to search for tasks
- Navigate to the task show page when selected in the autocomplete control
18. Styling and displaying dates and times
- Load a CSS framework in the HTML
- Add page padding using a section and style page headings
- Add a nav element and style it using the navbar component
- Style the notification messages with optional JavaScript to dismiss them
- Add styles and layout to the signup form
- Style the remember me checkbox in the login form
- Format form hint text and file input controls
- Style action links as buttons
- Style description lists using typography helper classes
- Add styles to tables and pagination links
- Display dates and times in a more readable format
19. Internationalization & localization: show content in more than one language
- Create files to store translations and display translated text in the browser
- Translate text in views: text in HTML elements
- Translate flash messages: organise translations using nested messages
- Translate validation messages: manually and with the translations package
- Set the application locale based on the browser's language settings
- Specify the locale code in the URL
- Include the locale code in the form action URL using a global view variable
- Translate the signup success message and activation email content
- Route placeholders: add a route for activation with the locale and token
- Route groups: reduce the code needed to specify routes with a common prefix
- Internationalise and localise the login and password reset controllers
- Add the locale to navigation links and translate the homepage and navigation
- Select the homepage language with the locale code in the URL
- Require the locale code on the homepage and add language selection links
- Remember the locale in the session for URLs without the locale
- Restore the flash messages shown when logging in and logging out
20. Deployment: install the application on a production server
- Create an example .env file containing settings that differ between environments
- Create a controller to seed the database from the browser
- Copy the files to the production server
- Configure the application on the live server