CodeIgniter 4 book from scratch + integration with Bootstrap 5
This is the most comprehensive CodeIgniter 4 book you'll find. We'll cover everything from the basics, such as routes, controllers, views, models, form handling, and validations, to more advanced topics like REST APIs with authentication tokens.
- Authorization using CodeIgniter Shield for permissions.
- Essential packages and much more.
You can see the book details at the bottom of this post. Best of all, it's an investment for several years, as I'll maintain the book and book for free for several years, including updates.
Foreword
This guide is intended to get you started with CodeIgniter 4; with this, we are going to establish two things:
- We do not pretend that the person gets to know 100% Codeigniter from zero to expert, since it would be too big an objective for the scope of what is written here, if not, to know its ecosystem, what it offers us and how it works based on several examples and/or small applications with limited scope.
- The reader is expected to have knowledge of JavaScript, HTML and CSS as they are necessary to be able to develop in any PHP framework, or server-side web you want to learn; on my website desarrollolibre.net I have multiple resources that may interest you to take the first steps with various technologies for free; just like on my YouTube channel, you have a lot of free, unique and quality material.
Who is this book for
This book is for anyone who wants to build their first applications in CodeIgniter 4, this writing offers a step-by-step introduction to the framework, knowing the most relevant aspects of it and is focused above all on practice; It is assumed that the reader has knowledge and has developed in PHP and related technologies of the language, such as JavaScript, HTML and CSS, since, remember that to use any framework, you have to have the bases that support it, that is, your programming language.
The book is aimed at those people who want to learn something new, learn about a framework that has very little documentation, who want to improve a skill in web development, who want to grow as a developer and who want to continue scaling their path with other frameworks superior to this one. As long as you identifies at least some of the above considerations, this book is for you.
- Previous technical requirements
- You need to have solid foundations in:
- PHP
- HTML
- CSS
- JavaScript
- I emphasize this because, in my experience, those who arrive without these foundations often get frustrated quickly when they encounter concepts like controllers or dynamic views.
- Ideal student profile if you want to:
- Build your first real apps
- Learn a modern but simple PHP framework
- Access clear documentation in Spanish
- Create APIs, user modules, administrators, and complete CRUDs
- Build the path to more complex frameworks
Topics of the book
This book has a total of 21 chapters, it is recommended that you read in the order in which they are arranged and as we explain the components of the framework, go directly to the practice, replicate, test and modify the codes that we show in this book.
- Chapter 1: This chapter is intended to explain the environment needed to develop in CodeIgniter 4.
- Chapter 2: We take the first steps with the frameworks, we will know the official website of the framework, installation forms and advantages of each one of them, we install the framework, we will know the initial aspects on how to run the framework, configure a database, create our first components, the use of migrations for table management and we will see several cases on how to work with them, we will work with the MVC and create each of these components that define it from scratch, routing and of book, finishing the chapter with the traditional CRUD for one of our entities.
- Chapter 3: It is a practice for you, in which you have to create another CRUD; putting into practice everything seen in the first chapter.
- Chapter 4: You will know how to use the routes, grouped routes, their options and the different types.
- Chapter 5: We will know the use of the session and also of the flash session to save data and present it to the user.
- Chapter 6: You will learn to manage views in a reusable way.
- Chapter 7: We will see how to use a more modular scheme when defining controllers for each type of module.
- Chapter 8: We will know how to work with HTML forms and apply validations from the server side in CodeIgniter, knowing the types of validations, creating them and applying validations from the controller; to then finally show the errors by the view; we will also learn how to use helper functions in our forms.
- Chapter 9: We will learn more about models, some properties that we can define in them, the use of functions and common example cases.
- Chapter 10: We will learn to use filters to intercept requests; as a practical case, we will create an authentication module with login for our application in which we will protect the management module or dashboard.
- Chapter 11: In this chapter we build a Rest Api type CRUD that can be consumed with JSON or XML; being CRUD type operations and working mainly from the server side; it will be a process similar to the CRUD that we created in Chapter 2, but with some variations that are typical of this type of structure.
- Chapter 12: In this chapter you will learn to generate test data with seeders which are ideal for when we are starting to develop.
- Chapter 13: In this chapter we will learn how to handle the relational schema of the database in CodeIgniter; we will look at one-to-many and many-to-many relationships.
- Chapter 14: In this chapter we are going to work with uploading files in our application, to upload images to our movie model.
- Chapter 15: This chapter provides an introduction to the use of the libraries and help functions and how to use them.
- Chapter 16: This chapter we will adapt Bootstrap 5 components in the application.
- Chapter 17: This chapter we will create an end user module with list and detail page.
- Chapter 18: This chapter we will make some changes in the Rest Api created previously to define additional methods such as upload, pagination, among others.
- Chapter 19: App with Vue, coming soon.
- Chapter 20: In this chapter we will learn how to integrate the PayPal platform in CodeIgniter, in order to process payments directly from the application.
- Chapter 21: This chapter we will know how to integrate CodeIgniter shield to handle authentication and authorization; also, we will create a small project with which we will learn to manage groups and permissions.
Book Summary
On a technical level, you'll learn to work fluently with the following features in CodeIgniter:
- Install CodeIgniter 4 with composer and manually
- Start the CodeIgniter 4 service
- Explain CodeIgniter project structure
- Visual Studio Code as the IDE for developing in CodeIgniter
- Route handling
- Controllers, views, models, and routes
- Work with multiple views (layout)
- Database connection
- Forms for data management and validation
- Session and flash session
- File upload and PDF generation
- Move images and generate dynamic folders or directories
- Redirects and session messages
- Spark: Presentation of the CodeIgniter command line
- Seeder: Generate test data in our application
- CRUD with models
- The .env file in CodeIgniter 4
- Know the main libraries and helper functions in CodeIgniter
- Create custom Helper functions or helpers.
- Creation of CRUD-type RestApis
- Update our CodeIgniter 4 project
- User module with login registration
- Use of filters to intercept requests
- Move CodeIgniter 4 to production in an Apache environment
Integrate with Bootstrap 5:
- Nav
- Cards
- Alerts
- Modals
- Tables
- Images
- Carousel
- Buttons
- Grid and container
- Font Awesome for icons
Although I mentioned earlier that CodeIgniter is ideal for a beginner, it does not necessarily have to be used as a simple stepping stone to reach higher and work with more complete and complex frameworks such as Laravel or Symfony.
CodeIgniter is a fairly powerful framework that would be more than enough for most of the applications that we create in our day to day; It brings functionalities to work in an organized way through MVC, a routes layer, easy creation of Rest Api, validations, form processing, filters to intercept requests and a lot more functions that will surely help you when programming your applications.
Codeigniter, once learned, will help you get to know larger frameworks like Laravel, as many of its features exist in Laravel.
What you will learn in this CodeIgniter 4 book and Book
- Installation with Composer or manual
- You will learn to set up your work environment from scratch using Composer or with manual installation, depending on what you prefer. I also teach you how to start the built-in server and structure your project correctly.
- Routes, Controllers, Views, and Models (Real MVC)
- From the beginning, we work with the core of the framework:
- Simple and advanced Routes
- Controllers with organized methods
- Reusable Views and layouts
- Models connected to the database
- This is where many books fall short, but in my experience, when I made my first complete app, I understood that mastering these four elements makes you advance 10 times faster.
- Forms, Validations, and Sessions
- Handling forms with secure validation rules, custom messages, and the use of session and flash session for notifications.
We work on this section using real-world cases: creating, editing, and deleting records.
- Handling forms with secure validation rules, custom messages, and the use of session and flash session for notifications.
- Database Connection and practical CRUDs
- Configure the connection
- Understand the Query Builder
- Build a CRUD from scratch
- Use migrations and seeders to automate test data
- In my case, seeders became indispensable when I scaled my first apps and needed to populate dozens of tables in seconds.
- Files, PDFs, Uploads, and Dynamic Images
- File upload, image handling, PDF generation, and dynamic directory creation. One of the parts I enjoy explaining the most because it gives you immediate power to build complete administrative panels.
- Rest API + token authentication
- We create a complete CRUD REST API and add token authentication.
Later, I include a small Vue app in the book to consume that API (it's in process, but students receive it for free once published).
- We create a complete CRUD REST API and add token authentication.
- User module with login and registration with Shield
- We implement a user system using sessions, validations, and best practices. Furthermore, I will teach authorization with CodeIgniter Shield, a tool that in my experience was a game-changer for handling roles and permissions with elegance.
- Use of Filters, Helpers, and Key Libraries
- Filters are ideal for intercepting requests; helpers, for reducing repetitive code. I use both constantly in my real projects, and here I teach you how to create your own custom helpers.
- Moving a CodeIgniter 4 project to production
- I show you how to prepare your project for an Apache environment, configure .env, clean routes, optimize performance, and deploy correctly.
Book repository:
Github
A demo of the app:
The book is currently in development...
I agree to receive announcements of interest about this Blog.
Book to take the first steps with CodeIgniter 4, in which we will see from how to install the framework, its basic structure and present its most important components.
Algunas recomendaciones:
Benjamin Huizar Barajas
Laravel Legacy - Ya había tomado este curso pero era cuando estaba la versión 7 u 8. Ahora con la ac...
Andrés Rolán Torres
Laravel Legacy - Cumple de sobras con su propósito. Se nota el grandísimo esfuerzo puesto en este cu...
Cristian Semeria Cortes
Laravel Legacy - El curso la verdad esta muy bueno, por error compre este cuando ya estaba la versi...
Bryan Montes
Laravel Legacy - Hasta el momento el profesor es muy claro en cuanto al proceso de enseñanza y se pu...
José Nephtali Frías Cortés
Fllask 3 - Hasta el momento, están muy claras las expectativas del curso