Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make config variable available only in infyom view files #1088

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

krydos
Copy link

@krydos krydos commented Oct 26, 2023

After upgrade to laravel 10 and upgrading this library we noticed that every $config variable that we use in our blade files now suddenly has type of InfyOm\Generator\Common\GeneratorConfig instead of being something we want it to be.

After some research we found THIS COMMIT that registers $config for every view.

So expected behaviour is this (please note, myveiw.blade.php is not related to laravel-generator in any way):

// controller
return view('myview', ['config' => ['key' => 'value']]); // pass $config variable to myview.blade.php

// myview.blade.php
$config['key'] == 'value' // true

actual behaviour:

// controller
return view('myview', ['config' => ['key' => 'value']]); // pass $config variable to myview.blade.php

// myview.blade.php
$config['key'] == 'value' // false. Moreover $config is InfyOm\Generator\Common\GeneratorConfig.

This PR makes $config variable available for laravel-generator's views only.

@mitulgolakiya could you please help me to make sure it's valid change that doesn't break what was intended initially with that commit.

Thanks!

@abewartech
Copy link

i install https://laravel.com/docs/10.x/pulse on laravel 10, this commit effectively resolved an issue encountered during the installation of Laravel Pulse

Cannot use object of type InfyOm\Generator\Common\GeneratorConfig as array

@krydos
Copy link
Author

krydos commented Dec 11, 2023

Good catch @abewartech. It looks like Pulse is also using $config variable in some (e.g. here or here or here) blade files and this lib overrides the variable with its own class.

As a temp solution you need several steps:

  1. create your custom InfyOmGeneratorServiceProvider.php file in app/Providers folder
  2. copy the service provider provided by this lib. You can just copy this file. It's literally just a copy of the lib's service provider but with the fix from this PR.
  3. replace InfyOm\Generator\InfyOmGeneratorServiceProvider::class with your custom service provider (App\Providers\InfyOmGeneratorServiceProvider::class) in your config/app.php file. If you don't have it there then just add it.
  4. update composer.json file's extra.laravel.dont-discover" section and add "infyomlabs/laravel-generator" there ("dont-discover": ["infyomlabs/laravel-generator"]. This will force laravel to not auto discover the lib's service provider and use the custom one instead.

@krydos
Copy link
Author

krydos commented Dec 28, 2023

What I've just found is that other infyom packages also depend on the $config variable injection. At least adminlte-templates does.
My 'laravel-generator::*' isn't fixing the issue fully in this case. Is adminlte-templates the only template supported by laravel-generator?

@Karkisushant
Copy link

I think it would be helpful if Laravel Generator had a configuration option where we could specify directories or files to exclude, or conversely, include. After encountering the same issue while attempting to use Pulse, I believe right now the suitable solution is temporarily setting the "dont-discover" option to ["infyomlabs/laravel-generator"] until a patch is available.

@krydos
Copy link
Author

krydos commented Feb 20, 2024

As mentioned above adminlte-template package is also using this config variable provided by the InfyOmGeneratorServiceProvider.
I added this package to my PR as well so only laravel-generator and adminlte-templates are getting this variable passed through.

Seems working ok.

@leonelngande
Copy link

Also experiencing this conflict after upgrading to Laravel 10 and installing Laravel Pulse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants