VANHIEP.NET - Làm web giá rẻ - Thiết Kế Website - Thiết Kế Ứng Dụng Mobile
[Zend Framework] - Learn about Zend Config.

[Zend Framework] - Learn about Zend Config.

Zend Config is a powerful and versatile configuration management component provided by the Zend Framework. This component plays a pivotal role in facilitating the organization and retrieval of configuration data within PHP applications. With Zend Config, developers can seamlessly handle configuration settings for their projects, ranging from database connections and module configurations to application-wide parameters.

One of the key strengths of Zend Config lies in its support for various configuration file formats, including INI, XML, JSON, and YAML. This flexibility allows developers to choose the format that best suits their preferences and project requirements. Additionally, Zend Config provides a standardized and intuitive interface for accessing configuration values, promoting a consistent and streamlined approach to configuration management.

Whether you are working on a small-scale web application or a large enterprise-level project, Zend Config empowers developers to efficiently manage configuration settings, ensuring the flexibility and scalability of PHP applications. Its robust features and adaptability make Zend Config an essential tool for configuring and customizing diverse PHP projects.

 

Step 1: In the Controller directory of module, You create a new controller is ConfigController.

You must sure path to file is same in the image.

 

Step 2: Create a view for controlle, attention folder name is name of controller, you can see image below.

 

Step 3: Define a route for controller

In config directory in module folder, you open file module.config.php and define same below image.

There are items need attention are route, controller, view.Now on the brower request route /config/index, we are get a screen same below image.

 

Step 4: Pass array to zend config. we are define one array after pass this to zend config

we are have a object return

Step 5: Get data form zend config class.

 

Step 6: How to include constants in zend config class

 

Step 7: How to use Filter in Zend Framework 

The first you need require zend-filter library to your project, implementing it by command line 

php composer-1.phar require zendframework/zend-filter

You can see all library of zendframework in the link 

https://github.com/zendframework

After run command line. You must run composer auto load for reload new libraby, implement it by this command

composer dumpautoload

Now in your project. you can use filter same in the image below.

After that. You get return on the brower.

In the example above we are use StringToUpper of zend-filter.

 

Step 8: How to use multi filter and demo StripTags() filter of zend-filter

We are define 2 filter after that use processor queue.You can see code sam image below.

You can see h3 tag is removed from value of website, becouse we are use StripTags.

Step 9: How to use addToken in Zend config processor

We are define same image below.

We can see addToken function is replace old token by new token.