I'm trying to understand PSR-4 autoloading by writing a very basic example app that runs on the console.
Here is my app's (directory) structure:
app/
-library/auth/Author/AuthorInterface.php
-library/auth/Author/Author.php
-library/auth/Authorize/
-library/database/
-vendor/composer/
-vendor/autoload.php
-composer.json
-composer.lock
-composer.phar
-manager.php
All I'm trying to do is run manager.php and have it echo a return statement from Author.php
AuthorInterface.php:
namespace Vee\Auth\Author;
interface AuthorInterface
{
public function write();
}
Author.php
namespace Vee\Auth\Author;
class Author implements AuthorInterface
{
function __construct()
{
return "Hello";
}
public function write()
{
return "Hello.write";
}
}
manager.php:
require "vendor/autoload.php";
use Vee\Auth\Author;
echo new Author();
composer.json:
{
"autoload": {
"psr-4": {
"Vee\\": "library/"
}
},
"require": {
"monolog/monolog": "^1.21"
}
}
And here's the error that I see when I try to run manager.php:
$ php manager.php
Fatal error: Class 'Vee\Auth\Author' not found in /<path-to-app>/manager.php on line 7
I have already run:
$ php composer.phar update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Writing lock file
Generating autoload files
What am I missing?
EDIT:
I'm running PHP 5.5 on a Mac, if that makes any difference-
$ php --version
PHP 5.5.36 (cli) (built: Jun 12 2016 23:47:46)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies