I can not get the composer to work with my own classes / files using the psr-0 autoload mechanism. Can anyone shed some light on why the following does not work?
I get the following output in my error log:
PHP Fatal error: Class 'TestdirTest1' not found in /home/webroot/bitlama/index.php on line 5
It works if I uncomment the explicit request of require (index.php: 2).
And if someone asks a question - yes, I started the installation of the composer in the form: "php ../ composer.phar install".
This is my directory structure:
├── composer.json ├── index.php ├── testspacedir │ └── Testdir │ └── test1.php └── vendor ├── autoload.php └── composer ├── autoload_classmap.php ├── autoload_namespaces.php ├── autoload_real.php └── ClassLoader.php
composer.json:
{ "autoload": { "psr-0": { "Testdir\\": "testspacedir/"} } }
test1.php:
<?php namespace Testdir; class Test1 { public function __construct() { echo "Woohoo Test1"; } }
index.php:
<?php require 'vendor/autoload.php'; //require 'testspacedir/Testdir/test1.php'; $test1 = new Testdir\Test1();
seller / autoload.php:
<?php // autoload.php @generated by Composer require_once __DIR__ . '/composer' . '/autoload_real.php'; return ComposerAutoloaderInit7b4760e0f7ca9d6454dd2f098c374ba4::getLoader();
source share