InfyOmLabs / laravel-generator

API and Admin Panel CRUD Generator for Laravel.
https://www.infyom.com/open-source
MIT License
3.79k stars 812 forks source link

Couple fixes needed #179

Closed phillipmadsen closed 8 years ago

phillipmadsen commented 8 years ago

Just a heads up. When you change the default paths and namespaces it only changes in the config not on the files. They are currently all hardcoded.

Another note. When you use the App:Name change command it is not updating the files that are in your vendor folders.
example if I use the command to change it from App to Test these are not changing to allow for the files to still work. I will list the ones im having problems with.

FatalErrorException in AppBaseController.php line 13:
Class 'App\Http\Controllers\Controller' not found

use InfyOm\Generator\Controller\AppBaseController; use InfyOm\Generator\Common\BaseRepository;

phillipmadsen commented 8 years ago

also having problems with this //use Fully\Http\Controllers\AppBaseController as InfyOmBaseController; looks like its the same issue but with another name is all.

phillipmadsen commented 8 years ago

it looks like some of these are because im using another namespace then App\

so your use InfyOm\Generator\Utils\ResponseUtil; is referencing App\??? and breaking functionality.

Looks like all the places It needs to be changed are working except in your vendor files you are referencing. IS there a way to not reference files from the vendor folder for working crud output and reserve those calls to the generator functionality only? That way generated files will be self reliant and the developer can remove your package when its build without it breaking?

Just a thought

Hope this helps

phillipmadsen commented 8 years ago

ok dug a bit more and found the issue I think. When the generator is used if you have published templates it is not using the changed value in the published config it is using the default values in the vendor config folder instead.

for example config/infyo/laravel_generator.php

    'namespace' => [
        'model'             => 'Test\Models',
        'datatables'        => 'Test\DataTables',
        'repository'        => 'Test\Repositories',
        'controller'        => 'Test\Http\Controllers',
        'api_controller'    => 'Test\Http\Controllers\API',
        'request'           => 'Test\Http\Requests',
        'api_request'       => 'Test\Http\Requests\API',
    ],

AND IN vendor/infyomlabs/laravel-generator/config/laravel_generator.php is what is being used.

    'namespace' => [
        'model'             => 'App\Models',
        'datatables'        => 'App\DataTables',
        'repository'        => 'App\Repositories',
        'controller'        => 'App\Http\Controllers',
        'api_controller'    => 'App\Http\Controllers\API',
        'request'           => 'App\Http\Requests',
        'api_request'       => 'App\Http\Requests\API',
    ],
mitulgolakiya commented 8 years ago

@phillipmadsen AppBaseController is now not using hardcoded App\Http\Controllers\Controller. Instead it will use dynamic namespace and also AppBaseController is not published with prefix directory and configured directory.

Please test it once more with your use cases and let me know if it works.

You need to either install it with fresh repo or publish AppBaseController again after making changes in laravel_generator.php.