Laravel, Jenssegers & Cashier: Call to a member function prepare() on null - laravel

When using Laravel with Jenssegers/MongoDB and Cashier, I receive the error:
Call to a member function prepare() on null.

Browse to laravel/vendor/cashier/src/
Open both subscription.php and subscriptionItem.php and change
use Illuminate\Database\Eloquent\Model;
to
use Jenssegers\Mongodb\Eloquent\Model;

remove the composer.lock and run this command
composer require jenssegers/mongodb
after that run these command as well:
composer dump-autoload
php artisan cache:clear
php artisan view:clear
php artisan config:clear
and restart your server. also, make sure you have installed the latest version of composer.

Related

Php artisan serve in laravel

I am new in laravel development. I am using latest version 9 of laravel, when I write php artisan serve in git bash or in VS code terminal after sometime it gives an error. I attached a screenshot of an error.
run php artisan optimize command
composer install
composer update
php artisan optimize:clear
This will clear all the cache of the application

There are no commands defined in the "passport" namespace. When installing API Authentication In laravel

I am getting below error when i run
php artisan passport:install
[Symfony\Component\Console\Exception\CommandNotFoundException]
There are no commands defined in the "passport" namespace.
For installing laravel passport make sure you add this line to config/app.php in the providers array (package service providers section):
Laravel\Passport\PassportServiceProvider::class,
Then install the package and migrate the database
composer require laravel/passport
php artisan migrate
php artisan passport:install
Clearing out the cache is generally helpful first step when commands are not working, especially when you update anything in the config folder on .env files.
php artisan config:clear
php artisan config:cache
Config clear removes the configuration cache file. Config cache creates a new configuration cache file with the current settings. Config cache enables faster load times for your apps!
I got solution. After running following two commands every thing work fine.
run php artisan cache:clear
run php artisan config:cach
I was searching for a solution for this and I found simple one that worked for me:
Add these lines to $commands array in app/Console/Kernel.php
\Laravel\Passport\Console\InstallCommand::class,
\Laravel\Passport\Console\KeysCommand::class,
\Laravel\Passport\Console\ClientCommand::class,
Try running composer require laravel/passport "~9.0" before running php artisan passport:install
Just follow these steps:
composer require laravel/passport.
Once the installation finishes, add the following provider in the config/app.php file: Laravel\Passport\PassportServiceProvider::class,
php artisan migrate
php artisan passport:install
Here Is the solution of install Laravel passport with mongodb:
Just replace the Illuminate\Database\Eloquent\Model; with Jenssegers\Mongodb\Eloquent\Model in below files:
..\vendor\laravel\passport\src\Token.php,
..\vendor\laravel\passport\src\AuthCode.php
..\vendor\laravel\passport\src\Client.php
..\vendor\laravel\passport\src\PersonalAccessClient.php
and protected $table= "Table_name" variable with protected $collection="Table_name"

php artisan make:controller throws: method controller doesnt exists

I'm trying to create a controller on an Homestead install for Laravel.
If I try:
php artisan make:controller test
I get
[BadMethodCallException]
Method controller does not exist.
php version is 7, php artisan --version = 5.3
oh just writing the question I discovered an error in routes.php.
Corrected the error now everything is fine...

RuntimeException in Laravel 5.3

I've just installed Laravel 5.3. php artisan serv also runs.
But as I hit http://localhost:8000/ on browser I get a RuntimeException.
Is there any solution to prevent this error?
Create cipher key by this command
php artisan key:generate
Then run server
php artisan serve
To avoid this problem always use composer for creating project.
Ex. composer create-project laravel/laravel your_project_name --prefer-dist
if you create project by composer then need not to run this command.
php artisan key:generate

Unable to install Laravel's 5 cashier/stripe packages

I have put the "laravel/cashier": "~5.0" line in my composer.json file, updated it;
Next, I have put the line 'Laravel\Cashier\CashierServiceProvider' into $providers array in, app.php
Then, in cmd when I try to migrate table, php artisan cashier:table builder, i get the message:
[InvalidArgumentException] There are no commands defined in the "cashier" namespace.
Then, when I type: php artisan, there is no cashier:table command, what and where is the problem?
I had same problem and when I run that commands php artisan config:cache and php artisan clear-compiled it worked...

Resources