Home >Backend Development >PHP Tutorial >CodeIgniter system process, codeigniter process_PHP tutorial
-------------------------- -------------------------------------------------- -----------------------
Enter the framework entry file index.php =>
Define the current environment of the application (used to set error mode): define('ENVIRONMENT', 'development');
Set the system file directory name: $system_path = 'system';
Set the application file directory name: $application_folder = 'application'; //Can be customized
Define the current file name constant: define('SELF', pathinfo(__FILE__, PATHINFO_BASEPATH));
Define PHP file suffix constant: define('EXT', '.php'); //This global constant is not recommended to be used
Define system directory path constants: define('BASEPATH', str_replace('\', '/', $system_path));
Define the front-end controller file path constant: define('FCPATH', str_replace(SELF, '', __FILE__));
Define system directory name constants: define('SYSDIR', trim(strchr(trim(BASEPATH, '/'), '/'), '/'));
Define application directory path constant: define('APPPATH', BASEPATH.$application_folder.'/');
Load the boot file: require_once BASEPATH.'core/CodeIgniter.php';
---------------------------------@黑eyedpoet
Enter the system initialization file CodeIgniter.php =>
define('CI_VERSION', '2.2.0');
define('CI_CORE', FALSE);
require(BASEPATH.'core/Common.php'); //Introducing public function library files, including functions such as load_class()
require(APPPATH.'config/'.ENVIRONMENT.'/constants.php'); //Introducing framework constant files, file and directory mode & file stream mode
set_error_handler('_exception_handler'); //Define a custom error handler to record PHP errors
if ( ! is_php('5.3'))
{
@set_magic_quotes_runtime(0); // Kill magic quotes
}
if (isset($assign_to_config['subclass_prefix']) AND $assign_to_config['subclass_prefix'] != '')
//Set subclass prefix
{
get_config(array('subclass_prefix' => $assign_to_config['subclass_prefix']));
}
if (function_exists("set_time_limit") == TRUE AND @ini_get("safe_mode") == 0)
//Set a free script execution time limit
{
@set_time_limit(300);
}
$BM =& load_class('Benchmark', 'core');
//Instantiate the Benchmark benchmark class. This class allows you to mark points and calculate the time difference between them. Memory consumption can also be displayed
$BM->mark('total_execution_time_start');
//Benchmark mark, total execution time starts: $this->marker['total_execution_time_start'] = microtime();
$BM->mark('loading_time:_base_classes_start');
//Benchmark mark, loading time: $this->marker['loading_time:_base_classes_start'] = microtime();
$EXT =& load_class('Hooks', 'core'); //Instantiate the Hooks hook class to provide a mechanism to extend the basic system without stacking
$EXT->_call_hook('pre_system'); //Call the specified hook pre_system
$CFG =& load_class('Config', 'core'); //Instantiate the Config configuration class, including methods for managing configuration files
if (isset($assign_to_config))
{
$CFG->_assign_to_config($assign_to_config);
//Call the _assign_to_config method in Config.php to ensure that configuration items are assigned and rewritten through variables
}
$UNI =& load_class('Utf8', 'core'); //Instantiate Utf8 class to provide support for UTF-8 environment
$URI =& load_class('URI', 'core'); //Instantiate URI class, parse URI and determine routing
$RTR =& load_class('Router', 'core'); //Instantiate Router routing class, parse URI and determine routing
<🎜> , and the route set in the routing configuration file
if (isset($routing)) { $RTR->_set_overrides($routing); //Set controller overrides }
$OUT =& load_class('Output', 'core'); //Instantiate the Output output class, responsible for sending the final output to the browser
{
if ($OUT->_display_cache($CFG, $URI) == TRUE)
{
Exit; //Check whether there is a cache file, if so, exit the current script directly
}
$SEC =& load_class('Security', 'core'); //Instantiate the Security security class
$IN =& load_class('Input', 'core'); //Instantiate the Input input class and preprocess the global input data for safety
$LANG =& load_class('Lang', 'core'); //Instantiate the Lang language class
require BASEPATH.'core/Controller.php';, //Introducing the basic controller class
function &get_instance()
{
return CI_Controller::get_instance(); //Return static variable $instance
}
if (file_exists(APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller.php'))
{
require APPPATH.'core/'.$CFG ->config['subclass_prefix'].'Controller.php';
//Introduce custom extension basic controller class
}
if ( ! file_exists(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().'.php'))
{
show_error('Unable to load your default controller. Please make sure the controller specified in your Routes.php file is valid.');
}
include(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().'.php');
//Load local controller
$BM->mark('loading_time:_base_classes_end');
//Benchmark mark, the end of loading time: $this->marker['loading_time:_base_classes_end'] = microtime();
Security Check
$EXT->_call_hook('pre_controller'); //Call "pre_controller" hook
$BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_start'); //Benchmark mark, controller execution time mark point
$CI = new $class(); //Instantiate the request controller
$EXT->_call_hook('post_controller_constructor'); //Call "post_controller_constructor" hook
Call the requested method
$BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_end'); //Benchmark mark, controller execution time end mark point
$EXT->_call_hook('post_controller'); //Call "post_controller" hook
if ($EXT->_call_hook('display_override') === FALSE)
{
$OUT->_display(); //Send the final rendering output to the browser
}
$EXT->_call_hook('post_system'); //Call "post_system" hook
if (class_exists('CI_DB') AND isset($CI->db))
{
$CI->db->close(); //Close the database connection
}
-------------------------------------------------- --------------------------------------------------
Zend Framework takes a lot of time and is not suitable for quick learning.
There are many framework programs at home and abroad, such as speedphp, qeephp, cakephp, TP, etc.
According to the poster’s request, then there is only CI , I personally think it’s pretty good,
About CodeIgniter
CodeIgniter is a set of application development frameworks and toolkits for PHP website developers. It provides a rich set of standard libraries and simple interfaces and logical structures, aiming to enable developers to develop projects more quickly. Use CodeIgniter to reduce the amount of code you write and focus your energy on the creative development of your projects.
CodeIgniter was developed by Rick Ellis, CEO of Ellislab. Its core framework is specially written for this program, while many other class libraries, auxiliary functions and subsystems come from the content management system ExpressionEngine written by Rick Ellis and Paul Burdick. Inspiration from Ruby on Rails inspired us to create a PHP framework and bring the concept of frameworks into the general consciousness of the web community.
She is a small but powerful PHP framework. As a simple and "elegant" toolkit, she can build fully functional web applications for PHP programmers. If you are a developer who shares your hosting and is worried about client deadlines, if you are tired of those stupid and clunky frameworks, then CodeIgniter is what you need if...
* You Want a compact frame.
* You need great performance.
* You need broad compatibility with various PHP versions and configurations on standard hosts (e.g. PHP4).
* You want a framework that requires almost 0 configuration.
* You want a framework that doesn't require the command line.
* You want a framework that doesn't have to adhere to restrictive coding rules.
* You are not interested in large-scale integration libraries like PEAR.
* You don't want to be forced to learn a template language (although you can choose the template parser you ask for).
* You don’t like complexity and love simplicity.
* You need clear, complete documentation.
The most important thing is that CI’s documentation is simple, rich and easy to understand, haha
If you want to learn, you can go to CI China and have a look, you don’t need me to post the address for you
To be honest, I don’t know how to configure phpmyadmin, apache and other things under ubuntu.
But I have a question, did you install the Ubuntu virtual machine because you want to use codeigniter?
If this is the case, you can actually run it directly under windows. The first thing you have to do is install a server locally, because php is compiled by the server. Personally recommend xampp. After installation, make sure everything is running normally, and then check the status on localhost.
Okay, now let’s talk about codeigniter. codeigniter is a PHP framework. If you have not learned PHP, you must first lay the foundation of PHP before learning this. PHP has three ways of writing code (you can understand it this way, haha), regular, object-oriented, and MVC. Codeigniter uses the mvc method. MVC is Model, view and controller. Model is mainly used to call data in the database, and Controller can be understood as the middleman between model and view. It will get the value from the model and pass it to the view. View is the place used for display. Language examples: html, css, javascript.
How to use codeigniter?
After installing xampp, go to the installed folder to find htdocs, and then create a folder. Then just throw him in like this.
(The highlighted folder was created by me)
That’s basically it.
In fact, the most important thing now is to lay a good foundation. It seems from the question that you don't understand these things at all, so sometimes you are too lazy to answer questions like this. Hope you can find a solution.