PHP code example of rschaaphuizen / laravel-services
1. Go to this page and download the library: Download rschaaphuizen/laravel-services library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
bash
namespace App\Providers;
use App\Services\NameService;
use Illuminate\Support\ServiceProvider;
class ServicesServiceProvider extends ServiceProvider
{
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
//
}
/**
* Register the application services.
*
* @return void
*/
public function register()
{
$this->app->bind('NameService', function ($app) {
return new NameService();
});
}
}
bash
namespace App\Http\Controllers;
use App\Services\NameService;
use Illuminate\Http\Request;
class ExampleController extends Controller
{
/**
* @var NameService
*/
protected $nameService;
/**
* ExampleController constructor.
* @param NameService $nameService
*/
public function __construct(NameService $nameService)
{
$this->nameService = $nameService;
}
// the rest of your controller
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.