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!

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.

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

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

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

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

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

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

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


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Chinese version
Chinese version, very easy to use

Dreamweaver Mac version
Visual web development tools

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