laravel-enso / enso

Laravel Vue SPA, Bulma themed. For demo login use `admin@laravel-enso.com` & `password` -
https://www.laravel-enso.com
MIT License
1.08k stars 277 forks source link

enso:cli - defining model with namespace - error on generate files #254

Closed robbykrlos closed 4 years ago

robbykrlos commented 4 years ago

This is a bug.

Prerequisites

Description

When trying to define a model (option 0) in php artisan enso:cli in the new version 3.5.0 there is a problem while defining the full namespace.

According to documentation (and this worked on 3.3.6 i believe)

https://docs.laravel-enso.com/guide/development.html#using-the-cli

Model configuration:
name => Car

 Configure Model (yes/no) [no]:
 > y

 name:
 > App\\Vehicles\\Motorized\\Car

This should have worked, but now it give an warning on "only / is allowed".

If i change this to "App/Vehicles/Motorized/Car" it works to configure the Model, but it will break at step 6.Generate files when some files (i think migration was one of them) are generated with create_app/vehicles/motorized_/car_table....

The temporary workaround was to omit the full namespace and move the model afterwards.

Also, documentation (video included) does not fit anymore with new enso:cli options (there is a new 5th option "Package" which i don't know what it is at the moment.

If we clear some of these things up i could update the documentation Thank you.

aocneanu commented 4 years ago

We'll take care of the bug, you take care of the docs :)

Thanks.

vmcvlad commented 4 years ago

@robbykrlos I could not successfully replicate the issue specified in the second part of the description. Furthermore, please keep in mind that the namespace will always use App as it's first segment ( unless you are using the Package option, which is used for creating packages ) so it needs to be omitted when creating namespaced models

EG: ( App/Vehicles/Motorized/Car will generate namespace App\App\Vehicles\Motorized;).

This is the structure configuration I attempted:


Model image

Permission Group image

Permissions - yes to all

Files - yes to all


And these are the files generated by the pakage.

image

As you can see, the migration file seems to have been properly named. If you can provide a concise example I will be able to investigate further.

PS: This is a package specific issue, and should have been posted in the laravel-enso/cli repo.

robbykrlos commented 4 years ago

I'll come back tomorrow with exact log error and more details. As a first deviation from newer implementation, i used the documentation description with "App\...."

robbykrlos commented 4 years ago

When defining the model since \\ was not accepted anymore and it was recommended to use only /, I used App/models/profiles which was ok, but on step 6. Generate files this error poped:

` local.ERROR: file_put_contents(database\migrations\2019_10_14_120529_create_structure_for_app/_models/_profiles.php): failed to open stream: No such file or directory {"exception":"[object] (ErrorException(code: 0): file_put_contents(database\migrations\2019_10_14_120529_create_structure_for_app/_models/_profiles.php): failed to open stream: No such file or directory at C:\DATA\ENSO\vendor\laravel\framework\src\Illuminate\Filesystem\Filesystem.php:122) [stacktrace]

0 C:\DATA\ENSO\vendor\sentry\sentry\src\ErrorHandler.php(387): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'file_put_conten...', 'C:\\DATA\\SVN\\LBD...', 122, Array)

1 [internal function]: Sentry\ErrorHandler->handleError(2, 'file_put_conten...', 'C:\\DATA\\ENSO...', 122, Array)

2 C:\DATA\ENSO\vendor\laravel\framework\src\Illuminate\Filesystem\Filesystem.php(122): file_put_contents('database\\migrat...', '<?php\

\ use Lara...', 0)

3 C:\DATA\ENSO\vendor\laravel\framework\src\Illuminate\Support\Facades\Facade.php(239): Illuminate\Filesystem\Filesystem->put('database\\migrat...', '<?php\

\ use Lara...')

4 C:\DATA\ENSO\vendor\laravel-enso\cli\src\app\Writers\StructureMigrationWriter.php(29): Illuminate\Support\Facades\Facade::__callStatic('put', Array)

5 C:\DATA\ENSO\vendor\laravel-enso\cli\src\app\Services\Structure.php(52): LaravelEnso\Cli\app\Writers\StructureMigrationWriter->handle()

6 C:\DATA\ENSO\vendor\laravel-enso\cli\src\app\Services\Structure.php(32): LaravelEnso\Cli\app\Services\Structure->writeStructure()

7 C:\DATA\ENSO\vendor\laravel-enso\cli\src\app\Services\Generator.php(97): LaravelEnso\Cli\app\Services\Structure->handle()

8 C:\DATA\ENSO\vendor\laravel-enso\cli\src\app\Services\Generator.php(27): LaravelEnso\Cli\app\Services\Generator->write()

9 C:\DATA\ENSO\vendor\laravel-enso\cli\src\app\Commands\Cli.php(48): LaravelEnso\Cli\app\Services\Generator->handle()

10 C:\DATA\ENSO\vendor\laravel-enso\cli\src\app\Commands\Cli.php(54): LaravelEnso\Cli\app\Commands\Cli->index()

11 C:\DATA\ENSO\vendor\laravel-enso\cli\src\app\Commands\Cli.php(50): LaravelEnso\Cli\app\Commands\Cli->index()

12 C:\DATA\ENSO\vendor\laravel-enso\cli\src\app\Commands\Cli.php(54): LaravelEnso\Cli\app\Commands\Cli->index()

13 C:\DATA\ENSO\vendor\laravel-enso\cli\src\app\Commands\Cli.php(54): LaravelEnso\Cli\app\Commands\Cli->index()

14 C:\DATA\ENSO\vendor\laravel-enso\cli\src\app\Commands\Cli.php(54): LaravelEnso\Cli\app\Commands\Cli->index()

15 C:\DATA\ENSO\vendor\laravel-enso\cli\src\app\Commands\Cli.php(54): LaravelEnso\Cli\app\Commands\Cli->index()

16 C:\DATA\ENSO\vendor\laravel-enso\cli\src\app\Commands\Cli.php(54): LaravelEnso\Cli\app\Commands\Cli->index()

17 C:\DATA\ENSO\vendor\laravel-enso\cli\src\app\Commands\Cli.php(54): LaravelEnso\Cli\app\Commands\Cli->index()

18 C:\DATA\ENSO\vendor\laravel-enso\cli\src\app\Commands\Cli.php(35): LaravelEnso\Cli\app\Commands\Cli->index()

19 [internal function]: LaravelEnso\Cli\app\Commands\Cli->handle()

20 C:\DATA\ENSO\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(32): call_user_func_array(Array, Array)

21 C:\DATA\ENSO\vendor\laravel\framework\src\Illuminate\Support\helpers.php(522): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()

22 C:\DATA\ENSO\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(90): value(Object(Closure))

23 C:\DATA\ENSO\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(34): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))

24 C:\DATA\ENSO\vendor\laravel\framework\src\Illuminate\Container\Container.php(591): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)

25 C:\DATA\ENSO\vendor\laravel\framework\src\Illuminate\Console\Command.php(202): Illuminate\Container\Container->call(Array)

26 C:\DATA\ENSO\vendor\symfony\console\Command\Command.php(255): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))

27 C:\DATA\ENSO\vendor\laravel\framework\src\Illuminate\Console\Command.php(189): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))

28 C:\DATA\ENSO\vendor\symfony\console\Application.php(934): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

29 C:\DATA\ENSO\vendor\symfony\console\Application.php(273): Symfony\Component\Console\Application->doRunCommand(Object(LaravelEnso\Cli\app\Commands\Cli), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

30 C:\DATA\ENSO\vendor\symfony\console\Application.php(149): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

31 C:\DATA\ENSO\vendor\laravel\framework\src\Illuminate\Console\Application.php(90): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

32 C:\DATA\ENSO\vendor\laravel\framework\src\Illuminate\Foundation\Console\Kernel.php(131): Illuminate\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

33 C:\DATA\ENSO\artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

`

aocneanu commented 4 years ago

@vmcvlad can you see if this was solved or not?

vmcvlad commented 4 years ago

@robbykrlos did you disable validation? What were the intermediary configurations between defining the model namespace and generating files?

I attempted to generate a structure based on the model example you provided but once again, I could not replicate the issue:

image

image

Permissions -> Y to ALL

image

Files -> Y to ALL

Package -> N/A

Generate Output:

image

I would be grateful if you can provide the input data for each configuration step, as well as the order in which you configured the structure. Also, please ensure you are running version 3.3.6.

image

robbykrlos commented 4 years ago

@vmcvlad this was a one time error and it was 2 releases ago. I cannot easily simulate the exact scenario - and I do not remember the exact steps (it was not so straight forward - I remember I tried on model name multiple times to set a proper name with "\" and "\" and "/".

I suggest - if now it works without issues to close the ticket if nothing obvious can be found on that exception trace.

Thank you,

robbykrlos commented 4 years ago

Hi,

I have to reopen this:

I have the latest version :

image

You said that App is by default set - so no need to add it to the name of the model.

My models are under "App/Models/

In my error case I have my model called "Monitor" under "App/Models/Monitor"

image

In rest I have full this configuration:

image

image

image

image

I do not use [5]Packages nor disabled validation - [7]Toggle Validation

Error I get on [5] Generate:

  ErrorException  : file_put_contents(database\migrations\2019_11_13_170209_create_structure_for_models/monitors.php): failed to open stream: No such file or directory

  at C:\DATA\enso\vendor\laravel\framework\src\Illuminate\Filesystem\Filesystem.php:122
* @return int|bool
*/
public function put($path, $contents, $lock = false)
{
return file_put_contents($path, $contents, $lock ? LOCK_EX : 0);
}
...

As an workaround I do not give the sub-folder name in the model name anymore - and i'll deal later with moving the model file into the right path and correcting further paths.

robbykrlos commented 4 years ago

up:)

robbykrlos commented 4 years ago

Still happens. Started with model "App\Models\Condition". Error because of the wrong slash. Made it with "/" and then the migration file error from above.

raftx24 commented 4 years ago

Hi @robbykrlos, Thank you for reporting, it was solved.

robbykrlos commented 4 years ago

Hi @robbykrlos, Thank you for reporting, it was solved.

That's just awesome! Thank you too!

I'll close now the ticket.