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

Hidden commands showing in production build #401

Open
jwhulette opened this issue Mar 31, 2022 · 3 comments
Open

Hidden commands showing in production build #401

jwhulette opened this issue Mar 31, 2022 · 3 comments
Labels

Comments

@jwhulette
Copy link

jwhulette commented Mar 31, 2022

When compiling the phar the commands listed in the hidden section still show in the list.
I created a new cli application, built the phar and the following commands are shown:

➜ movie-cli cd builds/
➜ builds php application

Application unreleased

USAGE: application [options] [arguments]

inspire Display an inspiring quote
test Run the application tests

schedule:list List the scheduled commands
schedule:run Run the scheduled commands

stub:publish Publish all stubs that are available for customization

But they are in the hidden section
'hidden' => [
NunoMaduro\LaravelConsoleSummary\SummaryCommand::class,
Symfony\Component\Console\Command\DumpCompletionCommand::class,
Symfony\Component\Console\Command\HelpCommand::class,
Illuminate\Console\Scheduling\ScheduleRunCommand::class,
Illuminate\Console\Scheduling\ScheduleListCommand::class,
Illuminate\Console\Scheduling\ScheduleFinishCommand::class,
LaravelZero\Framework\Commands\StubPublishCommand::class,
],

If I add them to the remove section, they do not show in dev or prod.

Also, how do I hide the test command in production?

@owenvoke
Copy link
Member

owenvoke commented Apr 2, 2022

I was trying to work this out the other day, you can add the following into your AppServiceProvider as a temporary workaround.
https://github.com/owenvoke/rugby-schedule/blob/main/app/Providers/AppServiceProvider.php#L18-L22

However, it seems that this command doesn't show up when receiving the list of all Artisan commands in this code:
https://github.com/laravel-zero/framework/blob/master/src/Kernel.php#L214

@owenvoke owenvoke added the bug label Apr 2, 2022
@jwhulette
Copy link
Author

@owenvoke This does work, thank you. But unfortunately it also hides the self-update command. Not sure why.

@caendesilva
Copy link

What I ended up doing, as did not know about the AppServiceProvider trick, was putting $this->setHidden(true); in my command constructors. This may not work for you @jwhulette as you want to hide vendor commands, but may be helpful for others who want more granular control.

public function __construct()
{
    parent::__construct();

    if (config('app.env', 'production') !== 'development') {
        $this->setHidden(true);
    }
}

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

No branches or pull requests

3 participants