THINKPHP5 Methods for loading static resource paths and constants

Source: Internet
Author: User
This article mainly introduces the THINKPHP5 load static resource path and constants of the relevant data, the need for friends can refer to the following

1. Load Static resource path

Greater than 5.0.4 version can be used directly

__ROOT__: Project directory

__static__: STATIC directory under project directory

__js__: Static/js directory under project directory

__css__: Static/css directory under project directory

We can use the view template to print the specific paths of these constants

<! DOCTYPE html>

The page output is as follows:

Projectname/public/static/projectname/public/static/js/projectname/public/static/css

Open the config file under the application folder, you can customize the resource constants according to your own needs, and define the constants to use them in the template file.

For example:

<?phpreturn ['  view_replace_str ' = [   ' __public__ ' and ' = ']. /public/static/admin ',  ' __root__ ' = '/',  ' __app__ ' = ' app/admin/',];

2. Pre-defined constants

Predefined constants are defined constants that are built into the system and do not change as the environment changes, including:

EXT class library file suffix (. php)

Think_version Frame Version number

3. Path constants

System and application path constants are used for the system's default directory specification, and can be redefined by redefining changes, which generally do not need to be changed if you do not want to customize the catalog.

DS Current system Directory separator Think_path Framework System directory Root_path framework app root App_path app directory (default = Application) Conf_path configuration directory (default = App_path) Lib_path System Class Library Directory (default is Think_path. ' library/') Core_path system core Class Library Directory (default = Lib_path. ' think/') trait_path system TRAIT Directory (default = Lib_path. ' Traits /') Extend_path Extension Class Library directory (default is Root_path. ' extend/') vendor_path third-party Class library directory (default is Root_path. ' vendor/') Runtime_path apply run-time directory (default is Root_path. ' runtime/') Log_path apply log directory (default = Runtime_path. ' log/') Cache_path The project template cache directory (default is Runtime_path. ' cache/') Temp_path app cache directory (default = Runtime_path. ' temp/')

4. System Constants

System constants change as the development environment changes or settings change.

Is_win whether the Windows environment Is_cli belongs to the command-line mode Think_start_time start run time (timestamp) think_start_mem start running memory consumption env_prefix environment variable configuration prefix

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.