A
A
artyvr2015-06-08 21:27:57
PHP
artyvr, 2015-06-08 21:27:57

How to use PHP composer class autoload?

composer began to study recently, however, like PHP , and in the course a question arose:
there is a pagination class ( Zebra_Pagination ), in composer.json of which there is

"autoload": {
        "psr-0": { "Zebra_Pagination": "" }
    }

and after composer install/update in vendor/composer/autoload_namespaces.php appears
'Zebra_Pagination' => array($vendorDir . '/stefangabos/zebra_pagination'),

tell me how to use this class?
I tried both
$pagination = new Zebra_Pagination();
and $pagination = new \Zebra_Pagination();
despite the fact that enumeration is not the best way, there are many more ...
however, the result is the same - the class was not found ... the
line require __DIR__ . '/../vendor/autoload.php';, of course, is present ...
thank you in advance ...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
D', 2015-06-08
@artyvr

$ composer dumpautoload -o
Should help.

$ php -f z.php 
 PHP Fatal error:  Class 'Zebra_Pagination' not found
$ composer dumpautoload -o
$ php -f z.php 
 PHP Notice:  Undefined index: REQUEST_URI in ....

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question