I have created a simple package on packagist for learning (tommytest/tommytest). It installs fine, but I have to run "composer dump-autoload -o" immediately after it is installed. Before manually running the dump-autoload I get this:
Fatal error: Class 'mysqlgridspace\Page' not found in C:\xampp\htdocs\simple\index.php on line 5
After manually running dump-autoload it works fine. Isn't it supposed to handle the autoload set-up automatically when the package is installed?
Here's my composer.json (located in: simple/vendor/tommytest/tommytest/composer.json)
{
"name": "tommytest/tommytest",
"type": "library",
"description": "Framework agnostic data grid",
"keywords": ["datagrid","data grid"],
"homepage": "https://github.com/escalibore/tommytest",
"license": "MIT",
"authors": [
{
"name": "Tommy Bert",
"email": "tom@tberthold.com",
"homepage": "http://tberthold.com",
"role": "Developer"
}
],
"require": {
"php": ">=5.3.0"
},
"autoload": {
"psr-4": {
"mysqlgridspace\\":"src/"
}
}
}
And my class file (located in: simple/vendor/tommytest/tommytest/src/Mysqlgridmain.class.php)
<?php
namespace mysqlgridspace;
class Page {
public function __construct()
{
echo "hello, i am a page.<br>";
}
}
class Book {
public function __construct()
{
echo "hello, i am a book.<br>";
}
}