I am playing with the Laravel custom package development with the Wheniwork composer package. This package doesn't use any namespace. So, I am confused on how can I use it on my custom Laravel package? I am not sure if I'd need to use require()
on my service provider but that doesn't looks clean.
This is what I have in my custom service provider:
public function register()
{
$this->app->singleton('wheniwork', function () {
return new Wheniwork();
});
}
It looks Laravel isn't detecting the Wheniwork()
class. If I try to dd()
the class from the custom web.php
file in my package like the following, it shows class not found.
Route::get('/contact', function () {
var_dump(new Wheniwork());
});
This could be cause the composer package which I'm requiring through my composer.json
file from my custom Laravel package has no namespace on it. Any idea what am I doing wrong or what would be the correct way to go about doing this?
Laravel composer.json
file:
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/",
"Vendor\\Author\\": "packages/vendor/wheniwork/src/"
}
}
And this is my custom Laravel package composer.json
file:
"autoload": {
"psr-4": {
"Vendor\\Wheniwork\\": "src"
}
}