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

Readme [Lumen]: Simpler solution for supporting additional Facades and a note on getting Eloquent mixin to work. #438

Closed
wants to merge 1 commit into from

Conversation

MitchellMcKenna
Copy link

@MitchellMcKenna MitchellMcKenna commented Feb 2, 2017

  • Currently docs suggest to create config/app.php just for aliases (but to rename it something else) and having to rename it back every time you need to re-generate your ide-helper files. Instead this suggests copying the config/app.php from vendor folder (just like you would do to override any other values in this config) and adding your aliases to it and leaving the file there.
  • Adds note on adding Eloquent to aliases array so that @mixin \Eloquent works for autocompletion.
  • Updates code sample to show adding aliases array to bottom of copied config/app.php instead.

- Currently docs suggest to create `config/app.php` just for aliases
  (but to renaming it something else) and having to rename it back every
  time you need to re-generate your ide-helper files. Instead suggest
  copying the config/app.php from vendor folder (just like you would do
  to override any other values in this config) and adding your aliases
  to it and leaving the file there.
- Also adds note on adding `Eloquent` to `aliases` array so that
  `@mixin \Eloquent` works for autocompletion.
@MitchellMcKenna MitchellMcKenna changed the title Readme [Lumen]: Simpler solution for Additional Facades and note on getting Eloquent mixin to work. Readme [Lumen]: Simpler solution for supporting additional Facades and a note on getting Eloquent mixin to work. Feb 2, 2017
@MitchellMcKenna
Copy link
Author

We might even be able to provide a vendor:publish command to copy the config/app.php from the vendor directory automatically, let me know if you'd like me to update the pull request with that.

@DarkGhostHunter
Copy link
Contributor

Currently, Lumen's config/app.php doesn't include any kind of array of Facades, so even by copying that file you won't get any Facade not already aliased.

I updated my pull for that particular reason also.

@mfn
Copy link
Collaborator

mfn commented Jan 3, 2020

@MitchellMcKenna do you feel this PR is still relevant?

@MitchellMcKenna
Copy link
Author

@mfn Yes, just tested out again with latest lumen version.

I was only able to get \Eloquent autocomplete to work, plus I had to update the call $app->withFacades() call in bootstrap/app.php with the alias as well:

$app->withFacades(true, [
    Illuminate\Database\Eloquent\Model::class => 'Eloquent',
]);

Not sure why that step is necessary as well.

Like @DarkGhostHunter said, Lumen doesn't use illuminate AliasLoader so adding aliases in config/app.php won't create the aliases for the app, just allow ide-helper to know about them when ide-helper pulls them here:

$facades = array_merge($facades, $this->config->get('app.aliases', []));
. This means you have to add your aliases in both places; in $app->withFacades() call for lumen to register them and in config/app.php for ide-helper to set them up for autocompletion.

I will update the pull request with $app->withFacades() change and make the readme clearer as well.

@kiding
Copy link

kiding commented Jul 10, 2020

After struggling for hours looking through #438 (comment) and #611 (comment) and even #723, and so many other issues, the cleanest way to tell Generator to include \Eloquent—even without creating config/app.php—I came up with is this:

class_alias(Illuminate\Database\Eloquent\Model::class, 'Eloquent');
$app->config->set('app.aliases', ['Eloquent' => Illuminate\Database\Eloquent\Model::class]);
$app->register(Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class);

That was rough, not to mention how we'd set up our project is somewhat peculiar. Not really recommended to everyone.

@mfn mfn added the lumen label Aug 30, 2020
@mfn mfn mentioned this pull request Feb 4, 2021
mfn added a commit to mfn/laravel-ide-helper that referenced this pull request Feb 19, 2023
I'm proposing to drop official suport for Lumen for the following reasons:
- Lumen itself is dead, per [1]
  > **Note:** In the years since releasing Lumen, PHP has made a variety of wonderful performance improvements. For this reason, along with the availability of [Laravel Octane](https://laravel.com/docs/octane), we no longer recommend that you begin new projects with Lumen. Instead, we recommend always beginning new projects with [Laravel](https://laravel.com).

  Laravel Octact is just Laravel and no one using ide-helper with it
  needs anything special.
- For now, the change is mostly on the logistics side (readme, run tests,
  issues). In the past we had some special code but over time this was
  already removed.
  For now people still can use it and nothing will break out of the blue,
  but eventually it might

There are a only a few Lumen related issues open currently which would
be closed by this (barryvdh#1105, barryvdh#1069, barryvdh#438).

[1] laravel/lumen@69b2657
@mfn mfn mentioned this pull request Feb 19, 2023
9 tasks
mfn added a commit to mfn/laravel-ide-helper that referenced this pull request Feb 19, 2023
I'm proposing to drop official suport for Lumen for the following reasons:
- Lumen itself is dead, per [1]
  > **Note:** In the years since releasing Lumen, PHP has made a variety of wonderful performance improvements. For this reason, along with the availability of [Laravel Octane](https://laravel.com/docs/octane), we no longer recommend that you begin new projects with Lumen. Instead, we recommend always beginning new projects with [Laravel](https://laravel.com).

  Laravel Octact is just Laravel and no one using ide-helper with it
  needs anything special.
- For now, the change is mostly on the logistics side (readme, run tests,
  issues). In the past we had some special code but over time this was
  already removed.
  For now people still can use it and nothing will break out of the blue,
  but eventually it might

There are a only a few Lumen related issues open currently which would
be closed by this (barryvdh#1105, barryvdh#1069, barryvdh#438).

[1] laravel/lumen@69b2657
barryvdh added a commit that referenced this pull request Feb 20, 2023
I'm proposing to drop official suport for Lumen for the following reasons:
- Lumen itself is dead, per [1]
  > **Note:** In the years since releasing Lumen, PHP has made a variety of wonderful performance improvements. For this reason, along with the availability of [Laravel Octane](https://laravel.com/docs/octane), we no longer recommend that you begin new projects with Lumen. Instead, we recommend always beginning new projects with [Laravel](https://laravel.com).

  Laravel Octact is just Laravel and no one using ide-helper with it
  needs anything special.
- For now, the change is mostly on the logistics side (readme, run tests,
  issues). In the past we had some special code but over time this was
  already removed.
  For now people still can use it and nothing will break out of the blue,
  but eventually it might

There are a only a few Lumen related issues open currently which would
be closed by this (#1105, #1069, #438).

[1] laravel/lumen@69b2657

Co-authored-by: Barry vd. Heuvel <[email protected]>
@mfn
Copy link
Collaborator

mfn commented Feb 20, 2023

Hey 👋🏼 whilst integration in Lumen might still work, due to decline in usage of Lumen and better alternatives like Laravel Octane, Lumen is not officially supported anymore (the state of affairs where never really great, to begin with)

@mfn mfn closed this Feb 20, 2023
d3v2a pushed a commit to d3v2a/laravel-ide-helper that referenced this pull request Feb 16, 2024
I'm proposing to drop official suport for Lumen for the following reasons:
- Lumen itself is dead, per [1]
  > **Note:** In the years since releasing Lumen, PHP has made a variety of wonderful performance improvements. For this reason, along with the availability of [Laravel Octane](https://laravel.com/docs/octane), we no longer recommend that you begin new projects with Lumen. Instead, we recommend always beginning new projects with [Laravel](https://laravel.com).

  Laravel Octact is just Laravel and no one using ide-helper with it
  needs anything special.
- For now, the change is mostly on the logistics side (readme, run tests,
  issues). In the past we had some special code but over time this was
  already removed.
  For now people still can use it and nothing will break out of the blue,
  but eventually it might

There are a only a few Lumen related issues open currently which would
be closed by this (barryvdh#1105, barryvdh#1069, barryvdh#438).

[1] laravel/lumen@69b2657

Co-authored-by: Barry vd. Heuvel <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants