Join Jon Peck for an in-depth discussion in this video Creating a static page controller, part of Up and Running with PHP CodeIgniter (2013).
- View Offline
In CodeIgniter, and other MVC frameworks for that matter, a controller can be…practically thought of as a class that delegates work.…Each controller is named so it can be accessed via URL.…To determine what controller to use, CodeIgniter uses the following pattern for…routing a user's request to the right controller.…Index.php, followed by the controller class, then the controller method, and…then any optional arguments. Let's take a look at how this default…message is being rendered. From Netbeans, navigate to the application…route, and open the controllers directory. There are two files in here: index.html,…which, when I open, I can see is just a simple place holder denying access.…
Close it, then open welcome.php. The first line is a safety mechanism that…prevents direct access to the controller. Then, a subclass declaration that extends…the codeIgniter controller class. The name of the class is Welcome, with a…capital W. This is different than the file name,…which is all in lower case. There's only one method within the class, index.…
Starting with the what and why of CodeIgniter, Jon introduces key concepts such as the MVC pattern and libraries by demonstrating how to create static pages, then storing and displaying magazine info in a database. Advanced topics like classes and helpers are explored to validate user input, upload files, and much more. By creating a complete system, you'll have the foundation to build your own applications with CodeIgniter.
- What is CodeIgniter?
- Creating a static page controller
- Generating output with a view
- What is a model?
- Saving data with Active Records
- Creating forms
- Validating user input
- Listing records in tables
- Uploading images
- Viewing and deleting records