mercredi 19 octobre 2016

Why package routes does not load the controller class?

I'm trying to add package in laravel 5.2.*, but package routes returning error Class FormController does not exist.

What i'm trying

Package Directory > packages\js\form\src

Package > Provider

namespace Js\Form;
use Illuminate\Support\ServiceProvider;
class FormServiceProvider extends ServiceProvider
{
    public function boot()
    {
    }

    public function register()
    {
        include __DIR__.'/routes.php';
        $this->app->make('Js\Form\FormController');
    }
}

Package > Controller

namespace Js\Form;  
use App\Http\Controllers\Controller;
use Carbon\Carbon;
class FormController extends Controller
{
    public function index()
    {
        echo 'test';
    }
}

Package > Composer

{
    "name": "js/form",
    "description": "this is form",
    "type": "project",
    "license": "xyz",
    "minimum-stability": "dev",
    "require": {}
}

Main Composer

"autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\\": "app/",
            "Js\\Form\\": "packages/Js/Form/src"
        }
    }

Package > Routes

Route::get('/contactus', 'FormController@index');

In the config/app.php

Js\Form\FormServiceProvider::class,

I executed this command also composer dump-autoload then tried to open this url http://localhost/project/public/index.php/contactus but its showing following error.

Class FormController does not exist

Can anyone guide me where is issue that i can fix it. I would like to appreciate, if someone guide me. Thank You



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire