I am new to using composer and have created a list of required projects in my composer.json file. I can use them within my index.php bootstrap file fine.
However I want to also be able to autoload my own project files outside of the vendor folder using composers autoloader. My folder structure is as follows:
vendor/
project/
Project.php
index.php
composer.json
index.php
<?php
require 'vendor/autoload.php';
new \Project\Project;
Project.php
<?php
namespace Project;
class Project {
}
composer.json
{
"autoload": {
"psr-4": {
"Project\\": "project"
}
}
}
This keeps coming up with the following error:
Fatal error: Class 'Product\Product' not found in index.php on line 5
What am i doing wrong? Or can I not use composers autoload to load my application files?
Edit
Turns out I needed to run composer dump-auto -o
to refresh the changes I made to the composer.json
file. Credit to @Quasduck who posted in the comments.