Using libraries downloaded by Composer in Zend Framework 1

0

What is the best way to use libraries downloaded by Composer along with Zend Framework 1?

I saw the next link , explaining how to do this procedure however in a way that does not seem to be much correct.

In a comment it is said to leave the vendor folder in the root of the project, and to use the Zend autoloader.

How to use autoloader for this purpose? Or should I use require_once ?

    
asked by anonymous 21.10.2014 / 18:25

1 answer

1

When you declare the dependencies of a project through composer.json , somehow you have to include those dependencies in your project. Let's assume that composer.json of your project looks like this:

{
    "require": {
        "zendframework/zendframework1": "1.*"
    },
}

The composer, after installing the dependencies, creates a vendor/autoload.php file, as you can see below:

.
├── composer.json
├── composer.lock
└── vendor
    ├── autoload.php
    ├── composer
    └── zendframework

So, it would be just a matter of creating a index.php file in the root (depends a lot on your project) and include the dependencies as follows:

<?php
require_once(__DIR__ . '/vendor/autoload.php');

I have not worked specifically with ZF1 projects for some time, but if you'd like I can see for you.

    
21.10.2014 / 19:32