PHP excellent framework codeigniter learning series - installation, configuration unified code style tool - editorConfig

download

  It can be downloaded from the official website , I am using CodeIgniter-3.1.7.

content

  Open the program directory to see the directory structure.

  I made a little modification here, created a new  index  directory, put  index.php  and some static files into this directory. The main purpose of this is to only expose the entry file  index.php in the root directory of the website, and put  other files such as the application  website business file directory  application  and the system file directory  system outside the website root directory, so as to avoid direct access by users. arrive.

  application - the website business file directory. It contains the cache directory, the configuration file (config) directory, the controller (controllers) directory, the model (models) directory, the view (views) directory, the log file (logs) directory and so on.

  index - the root directory of the website. It contains the only entry file index.php of the website, as well as some css files, js files, pictures and other static and publicly accessible resources.

  system - Framework system file directory. There are core files for the framework to run   , various packaged and available tool  libraries , language files  language , font files  fonts and so  on.

  user_guide - User manual.

  .editorconfig - Uniform code style file. This file is used to define the coding specification of the project. The editor's behavior will be consistent with that defined in the .editorconfig file, and its priority will be higher than the editor's own settings, which is very useful and necessary when multiple people develop projects collaboratively. Some editors support it, some don't.

indent_style sets the indentation style (tab is hard indentation, space is soft indentation)
indent_size uses an integer to define the number of columns to set the width of indentation, if indent_style is tab, this property defaults to tab_width
tab_width is set to an integer The number of columns to tab indent. The default is indent_size
end_of_line set the newline, the value is lf, cr and crlf
charset set the encoding, the value is latin1, utf-8, utf-8-bom, utf-16be and utf-16le, it is not recommended to use utf-8-bom
trim_trailing_whitespace Set to true to strip any whitespace at the beginning of newlines.
When insert_final_newline is set to true, it means that the file ends with a blank line.
root means that it is the top-level configuration file. When it is found to be set to true, it will stop looking for the .editorconfig file.

  .gitignore - Folders and files ignored by git operations.

  composer.json - the composer configuration file for the CI framework. Composer is a dependency management tool for PHP. It allows you to declare the codebases your project depends on and it will install them for you in your project. This means that you can install CI frameworks and load extensions through composer.

  contributing.md - tells you that CI is an open source framework and how you can participate in the project and contribute code.

  license.txt - MIT license agreement. More lenient, allows you to modify the code, and can also be used for commercial purposes.

  readme.rst - A self-introduction of CI, and also tells you the precautions when using the installation.

Install

  Follow the installation instructions to install. Worth noting, since I changed the default location of index.php. So you need to set the absolute path of the application  and  system  folders in index.php  . Also, in order to make the url address beautified (without .php). I added the following configuration to the server module corresponding to the nginx configuration:

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

  What does this sentence mean?

  $uri This is a variable of nginx, which stores the address accessed by users, such as: http://www.xxx.com/index.html, then $uri is /index.html

     $uri/ represents a directory accessed, for example: http://www.xxx.com/hello/test/, then $uri/ is /hello/test/

  $query_string represents the parameter string in the request line. For example: http://www.xxx.com/hello/test/index.php?a=3, then $query_string is a=3.

  The complete explanation is: try_files tries to read the files accessed by the user in the website directory. If the first variable exists, it will return directly; if it does not exist, continue to read the second variable, if it exists, return directly; if there is no direct jump Go to index.php and attach the parameter string.

  Before the rewrite configuration of nginx, we need to access http://www.example.com/index.php/welcome/index in this way. Now we can access the URL like http://www.example.com/welcome/index.

 

 

 

Reference documentation:

Unified code style tool - editorConfig

 ngx_http_core_module module

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325228575&siteId=291194637