I have created a new directory Library
in root of Laravel.
Inside I put the file with class:
class My {
//
}
So, in controller Laravel I try to get access to this class:
App\Library\My
But Laravel does not determine this path.
This is my code:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use View;
use App\Library\My;
class HomeController extends Controller
{
//
}
Since PHP 5.5, the class keyword is also used for class name resolution. You can get a string containing the fully qualified name of the ClassName class by using ClassName::class. This is particularly useful with namespaced classes. Copy Code namespace NS { class ClassName { } echo ClassName::class; }
A Controller is that which controls the behavior of a request. It handles the requests coming from the Routes. In Laravel, a controller is in the 'app/Http/Controllers' directory. All the controllers, that are to be created, should be in this directory.
Introduction. Laravel's events provide a simple observer pattern implementation, allowing you to subscribe and listen for various events that occur within your application. Event classes are typically stored in the app/Events directory, while their listeners are stored in app/Listeners .
As above, make sure it is placed in the App directory and make sure it is properly namespaced e.g.
<?php
$fOne = new \App\library\functions;
$isOk = ($fOne->isOk());
?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With