Author: Awais Farooq
-
Installation
The most straightforward way to get started with Yii2 is to use the basic application template provided by the Yii2 team. This template is also available through the Composer tool. Step 1 − Find a suitable directory in your hard drive and download the Composer PHAR (PHP archive) via the following command. Step 2 − Then move…
-
Overview
The Yii[ji:] framework is an open-source PHP framework for rapidly-developing, modern Web applications. It is built around the Model-View-Controller composite pattern. Yii provides secure and professional features to create robust projects rapidly. The Yii framework has a component-based architecture and a full solid caching support. Therefore, it is suitable for building all kinds of Web applications: forums,…
-
Security
XSS Prevention XSS means cross-site scripting. CodeIgniter comes with XSS filtering security. This filter will prevent any malicious JavaScript code or any other code that attempts to hijack cookie and do malicious activities. To filter data through the XSS filter, use the xss_clean() method as shown below. You should use this function only when you are submitting…
-
Internationalization
The language class in CodeIgniter provides an easy way to support multiple languages for internationalization. To some extent, we can use different language files to display text in many different languages. We can put different language files in application/language directory. System language files can be found at system/language directory, but to add your own language…
-
Adding JS & CSS
Adding JavaScript and CSS (Cascading Style Sheet) file in CodeIgniter is very simple. You have to create JS and CSS folder in root directory and copy all the .js files in JS folder and .css files in CSS folder as shown in the figure. For example, let us assume, you have created one JavaScript file sample.js and…
-
Benchmarking
Setting Benchmark Points If you want to measure the time taken to execute a set of lines or memory usage, you can calculate it by using Benchmarking points in CodeIgniter. There is a separate “Benchmarking” class for this purpose in CodeIgniter. This class is loaded automatically; you do not have to load it. It can…
-
Application Profiling
When building a web application, we are very much concerned about the performance of the website in terms of how much time the controller took to execute and how much memory is used. Not only the performance, but we also need to see the insights of data like POST data, data of database queries, session…
-
Page Redirection
While building web application, we often need to redirect the user from one page to another page. CodeIgniter makes this job easy for us. The redirect() function is used for this purpose. Syntax redirect($uri = ”, $method = ‘auto’, $code = NULL) Parameters $uri (string) − URI string$method (string) − Redirect method (‘auto’, ‘location’ or ‘refresh’)$code (string) − HTTP Response…
-
Page Caching
Caching a page will improve the page load speed. If the page is cached, then it will be stored in its fully rendered state. Next time, when the server gets a request for the cached page, it will be directly sent to the requested browser. Cached files are stored in application/cache folder. Caching can be enabled on…
-
Common Functions
CodeIgniter library functions and helper functions need to be initialized before they are used but there are some common functions, which do not need to be initialized. These common functions and their descriptions are given below. Syntax is_php($version) Parameters $version (string) − Version number Return TRUE if the running PHP version is at least the one…