Author: Awais Farooq

  • Installation

    This chapter explains how to install FuelPHP framework on your machine. FuelPHP installation is very simple and easy. You have two methods to create FuelPHP applications − Let’s go through each of the methods one by one in detail in the subsequent sections. System Requirements Before moving to installation, the following system requirements have to…

  • Introduction

    FuelPHP is an open source web application framework. It is written in PHP 5.3 and implements HMVC pattern. HMVC is Hierarchical Model-View-Controller framework that allows to sub-request the controller, which returns the partial page such as comments, menus, etc., instead of the complete page as in normal MVC. FuelPHP is created with a desire to incorporate best practices from…

  • File upload

    To work on file upload we are going to use the form helper. Here, is an example for file upload. Example Make Changes in the config/routes.php file, as shown in the following program. config/routes.php Create a FilesController.php file at src/Controller/FilesController.php. Copy the following code in the controller file. Ignore, if already created. Create uploads/ directory in src/. The files…

  • Date and Time

    To work with date and time in cakephp4, we are going to make use of the available FrozenTime class. To work with date and time, include the class in your controller Let us work, on an example and display date and time, using FrozenTime class. Example Make Changes in the config/routes.php file as shown in…

  • Pagination

    If we want to show a set of data that is huge, we can use pagination and this feature is available with cake php 4 which is very easy to use. We have a table titled “articles” with following data − Let us use pagination to display the data in the form of pages, instead…

  • Creating Validators

    Validator can be created by adding the following two lines in the controller. Validating Data Once, we have created validator, we can use the validator object to validate data. The following code explains, how we can validate data for login webpage. Using the $validator object, we have first called the notEmpty() method, which will ensure that the…

  • Validation

    Often while making websites, we need to validate certain things before processing data further. CakePHP provides validation package, to build validators that can validate data with ease. Validation Methods CakePHP provides various validation methods in the Validation Class. Some of the most popular of them are listed below. Syntax Add(string $field, array|string $name, array|Cake\Validation\ValidationRule $rule…

  • Security

    Security is another important feature while building web applications. It assures the users of the website that, their data is secured. CakePHP provides some tools to secure your application. Encryption and Decryption Security library in CakePHP provides methods, by which we can encrypt and decrypt data. Following are the two methods, which are used for…

  • Cookie Management

    Handling Cookie with CakePHP is easy and secure. There is a CookieComponent class which is used for managing Cookie. The class provides several methods for working with Cookies. To work with cookies, add this 2 classes to your controller − The cookie object has to be created first to register a cookie. The name and…

  • Session Management

    Session allows us to manage unique users across requests, and stores data for specific users. Session data can be accessible anywhere, anyplace, where you have access to request object, i.e., sessions are accessible from controllers, views, helpers, cells, and components. Accessing Session Object Session object can be created by executing the following code. Writing Session…