VANHIEP.NET - Làm web giá rẻ - Thiết Kế Website - Thiết Kế Ứng Dụng Mobile
[Zend Framework] - Using Zend Config to read data from an INI file

[Zend Framework] - Using Zend Config to read data from an INI file

Zend Config is a powerful tool enabling seamless data retrieval from INI files in PHP applications. With its intuitive functionality, developers effortlessly parse and access configurations stored in INI format. Leveraging Zend Config ensures efficient data retrieval, simplifying the integration of settings or parameters stored within INI files into PHP projects.

Step1 : Create file config ini

Create ini folder path : module \ Hello \ config \ ini . In this directory create file module.config.ini. You can define content in file same image.

[Zend Framework] - Using Zend Config to read data from an INI file

Step 2: Reader file ini

 

 

In controller you can use Zend Config for read file ini same image below

[Zend Framework] - Using Zend Config to read data from an INI file

We are result on the brower.

[Zend Framework] - Using Zend Config to read data from an INI file

Step 3: Understanding more about the writing process in an INI file

+ You can use the semicolon (;) to comment on lines for notes in the INI file

+ To differentiate between levels within an array, you can use any characters, but you need to declare those characters to Zend Config when reading the file.

[Zend Framework] - Using Zend Config to read data from an INI file

[Zend Framework] - Using Zend Config to read data from an INI file

[Zend Framework] - Using Zend Config to read data from an INI file

+ If there are more than one array-qualifying characters in a sequence, we will obtain subarrays

[Zend Framework] - Using Zend Config to read data from an INI file

[Zend Framework] - Using Zend Config to read data from an INI file

 

+ Declare a section in the INI file

[Zend Framework] - Using Zend Config to read data from an INI file

[Zend Framework] - Using Zend Config to read data from an INI file

 

+ How to declare an INI file from a controller using the Zend Config class.

[Zend Framework] - Using Zend Config to read data from an INI file

[Zend Framework] - Using Zend Config to read data from an INI file

 

+ If we declare the delimiter for the array...

 

[Zend Framework] - Using Zend Config to read data from an INI file

 

[Zend Framework] - Using Zend Config to read data from an INI file

 

+ Declare a configuration file for the module.

Create a module.config.ini file in the config directory and use the structure of the module.config.php file to declare the content for this file

[Zend Framework] - Using Zend Config to read data from an INI file

We get the result

[Zend Framework] - Using Zend Config to read data from an INI file

 

 

+ Declare configurations in multiple different files, then merge them together

We create a file named controller-view.php to declare configurations for the controller and view. Create a file named router.ini to declare configurations for the router.

[Zend Framework] - Using Zend Config to read data from an INI file

[Zend Framework] - Using Zend Config to read data from an INI file

And then in the module file, we merge these files together.

[Zend Framework] - Using Zend Config to read data from an INI file

And we obtain the result as follows

[Zend Framework] - Using Zend Config to read data from an INI file

+ Separate INI configuration files

We create a file named router-hello.ini and declare the content of the route as follows

[Zend Framework] - Using Zend Config to read data from an INI file

Then use the include command to insert it into the router.ini file

[Zend Framework] - Using Zend Config to read data from an INI file

We still get the same result, nothing changes. Therefore, in large projects, we should separate different parts to make the code clearer and more readable

[Zend Framework] - Using Zend Config to read data from an INI file