search
HomePHP FrameworkThinkPHPThinkPHP5.2: Changes in configuration classes

ThinkPHP5.2: Changes in configuration classes

This article summarizes the adjustments in configuration class design in the latest version 5.2.

Cancel convention configuration

The convention configuration file (convention.php) has been officially canceled in the latest version. Before that, it had been moved from the core package to the application warehouse ( root directory). Since the default configurations have all been used as the default attribute configurations of related class libraries, the conventional configuration files are no longer needed.

From the perspective of convenient project configuration, the default configuration is provided under the config directory of the application warehouse, which makes modifications clearer and the configuration can be modified directly.

Cancel dynamic settings

It is recommended that the configuration class be only used for reading and not for dynamic settings, so as to facilitate the unified use of the configuration center management in the future. If third-party configuration extensions (such as Yaconf) are used, setting configuration is not supported. Therefore, the configuration class no longer provides a method for dynamically setting a certain configuration parameter, but due to the needs of some database configurations, the usage of a certain configuration file in batches is retained.

The following usage is no longer supported

Config::set('app.app_name', 'think');

The batch (merge) setting usage is retained

Config::set([
    'app_name' => 'think',
    'default_timezone' => 'Asia/Shanghai',
], 'app');

Unified configuration read operation

The previous pull method for reading first-level configuration has been cancelled. The new version uses the get method to read all configuration values, and the system will automatically judge.

At the same time, the default prefix of the configuration parameters (first-level configuration) is cancelled. All configuration parameters without a dot are considered to read the first-level configuration.

// 读取app配置
Config::get('app');
// 读取具体配置必须改为
Config::get('app.app_name');
// 不再支持原来的读取
Config::get('app_name');

The Config class no longer supports array reading

The Config class no longer uses the ArrayAccess interface, so it no longer supports array reading.

Routing and URL configuration are independent

The configuration parameters related to routing and URL requests are independently configured into the route.php configuration file instead of the app.php configuration file.

PHP Chinese website has a large number of free ThinkPHP introductory tutorials, everyone is welcome to learn.

This article is reproduced from: https://blog.thinkphp.cn/962855

The above is the detailed content of ThinkPHP5.2: Changes in configuration classes. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:ThinkPHP官网. If there is any infringement, please contact admin@php.cn delete
What Are the Key Features of ThinkPHP's Built-in Testing Framework?What Are the Key Features of ThinkPHP's Built-in Testing Framework?Mar 18, 2025 pm 05:01 PM

The article discusses ThinkPHP's built-in testing framework, highlighting its key features like unit and integration testing, and how it enhances application reliability through early bug detection and improved code quality.

How to Use ThinkPHP for Building Real-Time Stock Market Data Feeds?How to Use ThinkPHP for Building Real-Time Stock Market Data Feeds?Mar 18, 2025 pm 04:57 PM

Article discusses using ThinkPHP for real-time stock market data feeds, focusing on setup, data accuracy, optimization, and security measures.

What Are the Key Considerations for Using ThinkPHP in a Serverless Architecture?What Are the Key Considerations for Using ThinkPHP in a Serverless Architecture?Mar 18, 2025 pm 04:54 PM

The article discusses key considerations for using ThinkPHP in serverless architectures, focusing on performance optimization, stateless design, and security. It highlights benefits like cost efficiency and scalability, but also addresses challenges

How to Implement Service Discovery and Load Balancing in ThinkPHP Microservices?How to Implement Service Discovery and Load Balancing in ThinkPHP Microservices?Mar 18, 2025 pm 04:51 PM

The article discusses implementing service discovery and load balancing in ThinkPHP microservices, focusing on setup, best practices, integration methods, and recommended tools.[159 characters]

What Are the Advanced Features of ThinkPHP's Dependency Injection Container?What Are the Advanced Features of ThinkPHP's Dependency Injection Container?Mar 18, 2025 pm 04:50 PM

ThinkPHP's IoC container offers advanced features like lazy loading, contextual binding, and method injection for efficient dependency management in PHP apps.Character count: 159

How to Use ThinkPHP for Building Real-Time Collaboration Tools?How to Use ThinkPHP for Building Real-Time Collaboration Tools?Mar 18, 2025 pm 04:49 PM

The article discusses using ThinkPHP to build real-time collaboration tools, focusing on setup, WebSocket integration, and security best practices.

What Are the Key Benefits of Using ThinkPHP for Building SaaS Applications?What Are the Key Benefits of Using ThinkPHP for Building SaaS Applications?Mar 18, 2025 pm 04:46 PM

ThinkPHP benefits SaaS apps with its lightweight design, MVC architecture, and extensibility. It enhances scalability, speeds development, and improves security through various features.

How to Build a Distributed Task Queue System with ThinkPHP and RabbitMQ?How to Build a Distributed Task Queue System with ThinkPHP and RabbitMQ?Mar 18, 2025 pm 04:45 PM

The article outlines building a distributed task queue system using ThinkPHP and RabbitMQ, focusing on installation, configuration, task management, and scalability. Key issues include ensuring high availability, avoiding common pitfalls like imprope

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software