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

[5.x] Calling commands from addons #9861

Closed
robdekort opened this issue Apr 11, 2024 · 14 comments
Closed

[5.x] Calling commands from addons #9861

robdekort opened this issue Apr 11, 2024 · 14 comments

Comments

@robdekort
Copy link
Contributor

Bug description

I have an addon that adds certain commands to Peak sites. In some of those commands I call other Artisan commands:

  1. Artisan::call('cache:clear');
  2. Artisan::call('statamic:glide:clear')

In one command I call them both.

In v5 Alpha 1 and 2 triggering those commands leads to an error:
Screenshot 2024-04-11 at 09 32 27

When I replicate those commands in my actual project (and not in an addon) they work without issue. I can replace the cache:clear command with \Illuminate\Support\Facades\Cache::clear() and that works, however there's no alternative like that for the statamic:glide:clear command.

How to reproduce

  1. Install the v5 alpha.
  2. Create an addon.
  3. Add a simple command to the addon.
  4. Call an artisan command from the addon.

Logs

No response

Environment

Environment
Application Name: Statamic Peak Development
Laravel Version: 11.3.1
PHP Version: 8.3.4
Composer Version: 2.7.1
Environment: local
Debug Mode: ENABLED
URL: statamic-peak.test
Maintenance Mode: OFF

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: statamic
Database: sqlite
Logs: stack / single
Mail: smtp
Queue: sync
Session: file

Statamic
Addons: 4
Sites: 1
Stache Watcher: Enabled
Static Caching: Disabled
Version: 5.0.0-alpha.2 PRO

Statamic Addons
studio1902/statamic-peak-browser-appearance: dev-feature/v5-support
studio1902/statamic-peak-commands: dev-feature/v5-support
studio1902/statamic-peak-seo: dev-feature/v5-support
studio1902/statamic-peak-tools: dev-feature/v5-support

Installation

Starter Kit using via CLI

Antlers Parser

None

Additional details

No response

@duncanmcclean
Copy link
Member

I'm assuming you were doing it inside php please command, correct?

Can you try running that same command but with Artisan, so php artisan statamic:*?

@robdekort
Copy link
Contributor Author

Correct, and that makes it work Duncan!

@duncanmcclean
Copy link
Member

Cool, thanks for testing! We probably need to do some more tweaking on our side regarding how please works (related: #9729).

@robdekort
Copy link
Contributor Author

Cool, glad you're on the right path!

@robdekort
Copy link
Contributor Author

robdekort commented Apr 18, 2024

Screenshot 2024-04-18 at 09 51 44

On Alpha 4, I still notice an issue with the glide command. Notice in the screenshot above that:

  • php artisan statamic:peak:clear-site works
  • php please peak:clear-site does not work

The artisan cache:clear command (that is also part of clear-site) however ran without issue.

@robdekort robdekort reopened this Apr 18, 2024
@duncanmcclean
Copy link
Member

duncanmcclean commented Apr 18, 2024

Not saying it's the fix but can you try Artisan::call('peak:clear-site') (so without the statamic: prefix)?

@robdekort
Copy link
Contributor Author

Do you mean Artisan::call('glide:clear')?

@duncanmcclean
Copy link
Member

duncanmcclean commented Apr 18, 2024

Sorry, yeah.

@robdekort
Copy link
Contributor Author

Yep, that works!

@robdekort
Copy link
Contributor Author

Should I just use that and consider the case closed?

@duncanmcclean
Copy link
Member

Nah, leave it open, it should work with the statamic: prefix.

@jasonvarga
Copy link
Member

Nah I'd expect Artisan::call('statamic:glide:clear') to be what you need to run and not Artisan::call('glide:clear'). We'll sort it out. Thanks!

@robdekort
Copy link
Contributor Author

Hokey dokey. Thanks guys.

@jasonvarga
Copy link
Member

Fixed in #9926

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

No branches or pull requests

3 participants