Stuck at installing laravel/passport programmatically - php

To create a personal access client with passport in laravel, I need to run this command: php artisan passport:client --personal
I'm trying to run this command through Artisan::call('command', ['--flag'=>'value'])
The issue I'm having here is, passport prompts for an input to name the access token or accept a default one and the command gets stuck there. Is there any way I can give it any input? The Enter key press does the work on console.
Solution
Default Name: php artisan passport:client --personal --no-interaction
Custom Name: php artisan passport:client --personal --name=AccessTokenName
Found it in the source: https://github.com/laravel/passport/blob/2.0/src/Console/ClientCommand.php

Try running the command with the --no-interaction flag set. See php artisan passport:client --help for more options.

Related

Artisan shell executes too much time. How to fix?

I have 2 laravel apps.
On typing: "time php artisan" in first app, I see:
real 0m0.328s
user 0m0.123s
sys 0m0.057s
And if type the same at my "problem" project, I see:
real 1m15.887s
user 0m0.220s
sys 0m0.085s
I try to:
php artisan cache:clear
php artisan config:clear
php artisan debugbar:clear
php artisan route:clear
php artisan view:clear
composer said, that I have
laravel/framework v5.6.26 The Laravel Framework.
I try to drop "vendor" directory, and to run composer install command
it also doesn't helps. What should i do to fix so long time execution? php v 7.1.4
Few hours ago everything was ok! I was working only with controllers, (no any new artisan commands was made before bug shows)
~75sec for blank artisan coomand execution to show only commands list is too much...
I realy appreciate for any suggestions.

Not enough arguments (missing: "key"). in laravel php artisan cache:forget

When i try to remove my all cache file from laravel 5.5 project i got some error during run this command
php artisan cache:forget
Not enough arguments (missing: "key").
use command php artisan cache:forget -h for see list Arguments and options.
this is list agruments and option of cache:forget command larvel 5.4
Arguments:
key The key to remove
store The store to remove the key from
Options:
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
--env[=ENV] The environment the command should run under
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
if you want remove all cache file you can run this command
php artisan cache:clear
php artisan config:cache
and see more artisan command
php artisan list
You can use
php artisan cache:clear
after key generate with this command:
php artisan key:generate
For removing a entire Cache you can use Cache::flush();
For removing a key from Cache u can use Cache::forget('key') programmatically.
You can also use artisan console
php artisan cache:forget key="yourkey"
Hope this helps

oauth-private.key does not exist or is not readable

So, I imported another project from Bitbucket and tried to launch it using php artisan serve, I always get this error:
[LogicException]
Key path "file:///var/www/html/DesignViewer5/storage/oauth-private.key" does not
exist or is not readable
I don't get this error when I make a project myself, I can't run any other command. I tried 'php artisan key:generate', and got the exact same error.
I tried: composer update, and got this:
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 0 installs, 1 update, 0 removals
- Updating spatie/laravel-permission (1.11.1 => 1.12.0) Downloading: 100%
Writing lock file
Generating autoload files
> Illuminate\Foundation\ComposerScripts::postUpdate
> php artisan optimize
[LogicException]
Key path "file:///var/www/html/DesignViewer5/storage/oauth-private.key" doe
s not exist or is not readable
Script php artisan optimize handling the post-update-cmd event returned with error code 1
Anyone knows how to fix it? Thanks!
I think that this is due to Laravel Passport, you should try the following command:
php artisan passport:install
This command will create the encryption keys needed to generate secure
access tokens. In addition, the command will create "personal access"
and "password grant" clients which will be used to generate access
tokens
Source: https://laravel.com/docs/5.4/passport
I had the same problem when I updated the composer.I generated the keys again using php artisan passport:keys and it solved the problem
I found the solution
Solution:
In config/app.php I had to comment these lines:
/*Laravel\Passport\PassportServiceProvider::class,
App\Providers\CodeGrantProvider::class,
Spatie\Permission\PermissionServiceProvider::class,*/
Than you need to migrate the whole database again,
than uncomment this line:
Laravel\Passport\PassportServiceProvider::class,
And run php artisan passport:install my application keys weren't working so I had to do:
php artisan config:clear
php artisan key:generate
php artisan config:clear
And than I could do php artisan serve
Thanks!
so sample if you already install passpord and don't config run this command
php artisan passport:keys
If already doesnt install the passport package you must check the docs of passpord in Laravel docs
Step 1:
Only Run if oauth-private.key and oauth-public.key not exists in
storage folder otherwise skip first step..
php artisan passport:install
Step 2:
Clear configration and generate key
php artisan config:clear
php artisan key:generate
php artisan config:clear
Step 3:
Change permission and owner like that :
sudo chown www-data:www-data storage/oauth-*.key
sudo chmod 600 storage/oauth-*.key
Since /storage/*.key is in .gitignore so if you pull the project, that might be missing the key by running php artisan passport:keys will generate new keys for you.
Run: php artisan passport:install.
If get message like "Encryption keys already exist. Use the --force option to overwrite them."
Then run
Run: php artisan config:clear
Run: php artisan key:generate.
And finally
Run: php artisan config:clear
I have removed this bit: Passport::loadKeysFrom(__DIR__.'/../secrets/oauth');
from App\Providers\AuthServiceProvider and it fixed the issue.
https://laravel.com/docs/8.x/passport#deploying-passport
/**
* Register any authentication / authorization services.
*
* #return void
*/
public function boot()
{
$this->registerPolicies();
Passport::routes();
Passport::loadKeysFrom(__DIR__.'/../secrets/oauth');
}
if you use heroku as deployment,
try add this in composer.json at the script line
"post-install-cmd": [
"php artisan clear-compiled",
"chmod -R 777 storage",
"php artisan passport:keys"
]
and then run this command
php artisan passport:install
php artisan config:clear
php artisan optimize
do this commands
sudo chown www-data:www-data storage/oauth-*.key
php artisan passport:install
php artisan config:clear
php artisan key:generate
php artisan config:clear
Don't do this line until you have keys in a specific location for the file
in AuthServiceProvider.php
//Passport::loadKeysFrom('/secret-keys/oauth');
for my after i run composer install passport is already installed so php artisan passport:install does not help.
try to touch new file (oauth-private.key) to storage dir, then run command
php artisan passport:keys --force
this command 'll force override private key you touched and create "aouth-public.key" file. it 'll work fine
Depending on the environment you are using to deploy. If, for example, you are using a Heroku deploy, you may have to remove the folder containing the keys from gitignore before pushing and then later add it back. This worked for me after following the steps above.
firstly, search in oath-private-key in your application folder. copy
it and go to App/provider folder. create a new folder , secret and
oauth like that
App/Provider/Secret/Oauth and paste your oath-private-key here.
I hope it helps you.
For Windows OS. If you have already installed passport, or you are setting up an existing application and then facing this problem then try "php artisan passport:keys"

How do I remove old artisan command from Kernel in Laravel 5

I have created some Command files into my Laravel Application. Laravel version is 5.2. I set command like: get:email in the Command file. Also call the Command file into Kernel.php. After that I can see the artisan command list by typing the command php artisan list. as like as below:
//output
get:email
And I changed the command title get:email to get-bq:email. When I run the command php artisan get-bq:email -- its working nicely. Also I can see the list by typing the command php artisan list::
//output
get-bq:email
Issue / Problem: Both commands are working. But I won't to work with both of them. I have done the following things:
modified command file as well as command
run composer dump-autoload -o
run composer update
remove vendor and storage folder then run composer update again.
Still the old command is working into my system.
What I want: How May I remove my old commands from my Laravel(5.2) application?
Run these commands:
php artisan cache:clear
php artisan config:clear
These commands will clear app cache and config cache and recreate it.
I've had the same problem recently.
Repoeatedly tried
php artisan cache:clear
php artisan config:clear
and the cached Kernal command wouldn't clear.
In desperation i killed the queue worker terminal and restarted the queue with the command
php artisan queue:work
The issue stopped.

How to create a command for a Laravel 4 package?

The docs says that we can create a command for a package in Laravel 4.1 typing:
php artisan command:make AssignUsers --bench="vendor/package"
But it seems to not be working, I got the following error message:
[RuntimeException]
The "--bench" option does not exist.
Is there a way to create a command for a Laravel 4 package?
I used the standard artisan command to create a command into my package:
php artisan command:make CreateUsers \
--path="workbench/vendor/package/src/vendor/package"
After that, to make it available in the consumer application I had to add the following into my package's ServiceProvider (in the boot method):
$this->app->bind('vendor::command.user.create', function($app) {
return new UserCreateCommand();
});
$this->commands(array(
'vendor::command.user.create'
));
After that, everything will work fine.
when you run you will sse the list of arguments for make
php artisan command:make --help
you should see something like
Usage:
command:make [--command[="..."]] [--path[="..."]] [--namespace[="..."]] name
Arguments:
name The name of the command.
Options:
--command The terminal command that should be assigned.
--path The path where the command should be stored.
--namespace The command namespace.
--help (-h) Display this help message.
--quiet (-q) Do not output any message.
--verbose (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
--version (-V) Display this application version.
--ansi Force ANSI output.
--no-ansi Disable ANSI output.
--no-interaction (-n) Do not ask any interactive question.
--env The environment the command should run under.
as you can see from that output there is no argument bench
the proper way to do it is
php artisan command:make AssignUsers
then go to /app/start/artisan.php and add the following line
Artisan::add(new AssignUsers);
then edit the generated file in /app/commands/AssignUsers.php
change the value of $name to AssignUsers
and you are done.

Categories