Using libraries downloaded by Composer in Zend Framework 1

Asked

Viewed 195 times

0

How best to use libraries downloaded by Composer together with Zend Framework 1?

I saw in the following link, explaining how to do this but in a way that does not seem to be very correct.

In a comment is spoken of leaving the vendor folder on root of the project, and use the Zend autoloader.

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

1 answer

1

When you declare the dependencies of a project through composer.json, somehow you have to include these dependencies in your project. Suppose the composer.json of your project be so:

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

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

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

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

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

I haven’t worked specifically with ZF1 projects for some time, but if you want I can see it for you.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.