Reputation: 6763
Basically this is what I've done so far:
I have put my 3rd party library in app\library\WebName\Helper\Helper.php
.
This is the content of the Helper.php
namespace WebName\Helper;
class Helper {
public static function hello() {
return 'Hello!';
}
}
Then I modified the composer.json:
"classmap": [
"app/commands",
"app/controllers",
"app/library",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php"
]
And then I executed a composer dump-autoload
.
Now, the problem is that when I try to access the Helper
class, for example like in this controller:
use WebName\Helper;
class ValidationController extends BaseController {
public function sayHello() {
// Verification
echo Helper::hello();
}
I get the following error:
{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","message":"Class 'WebName\\Helper' not found","file":"C:\\xampp\\htdocs\\webname\\app\\controllers\\ValidationController.php","line":19}}
Upvotes: 0
Views: 405
Reputation: 212412
If class Helper
is in namespace WebName\Helper
, then surely you should be using
use WebName\Helper\Helper;
not
use WebName\Helper;
in your controller ?
Upvotes: 1