One of the most important features of Zend Framework 2.0 is the ability to integrate external modules in your PHP application, and this integration is completely managed using a dependency management tool (in ourcase, Composer).
This feature allows development of PHP applications without having to worry about maintaining external libraries inside your application. Libraries and applications can be decoupled and maintained separately.
In this chapter, we will be using an external module for resizing images; we will also make use of external libraries for connecting to Google services.
Resizing images
Zend Framework 1.0 had a resize filter that allowed images to be resized on upload; with Zend Framework 2.0, this option no longer exists. Our next task will be to find a simple image-resizing module and install it in our application. So let's get started.
Carry out the following steps:
1. Go to the Zend Framework 2 module's site:
2. Run a search for WebinoImageThumb.
3. To install this module, you will need to update composer.json in the application root and include this module as a required module.
4. To do this, edit CommunicationApp/composer.json and modify the required section:
"require": {
"php": ">=5.3.3", "zendframework/zendframework": "2.0.*", "webino/webino-image-thumb": "1.*",
}
5. Now run composer.phar update to install the newly added dependency.
$ php composer.phar update
Loading composer repositories with package information Updating dependencies
- Installing webino/webino-image-thumb (1.0.0)
Downloading: 100%
Writing lock file Generating autoload files
6. You will be able to see the newly installed modules in the vendor folder as follows:
7. Now that the module is downloaded, we will need to activate the module in CommunicationApp/config/application.config.php by adding 'WebinoImageThumb' to the modules array.
return array(
'modules' => array( 'Application',
'WebinoImageThumb', 'Users',
),
Không có nhận xét nào:
Đăng nhận xét