I'm getting this error...
Fatal error: Uncaught Error: Class 'TestApp\HelloWorld' not found in /Applications/MAMP/htdocs/php-framework/index.php:21 Stack trace: #0 {main} thrown in /Applications/MAMP/htdocs/php-framework/index.php on line 21
My guess is that composer.json is not connecting to the src folder, but not sure what's causing it. I'm using PHP 7.3.1
Here are my files:
index.php
declare(strict_types = 1);
require_once __DIR__ . '/vendor/autoload.php';
$helloWorld = new TestApp\HelloWorld();
$helloWorld->announce();
autoload.php
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInita3c559aaa188cb577ee6600701c362e7::getLoader();
HelloWorld.php
declare(strict_types = 1);
namespace TestApp;
class HelloWorld
{
public function announce(): void
{
echo 'Hello World!';
}
}
composer.json
{
"name": "philginsburg/php-framework",
"description": "An example of a modern PHP application.",
"type": "project",
"require": {},
"autoload": {
"psr-4": {
"TestApp\\": "src/"
}
}
}
Fatal error: Uncaught Error: Class 'TestApp\HelloWorld' not found in /Applications/MAMP/htdocs/php-framework/index.php:21 Stack trace: #0 {main} thrown in /Applications/MAMP/htdocs/php-framework/index.php on line 21