Tuesday, August 1, 2017

Laravel Cashier - There are no commands defined in the "cashier" namespace. [Solved]

In Laravel 5.4, when trying to use Laravel\Cashier, the following error can sometimes occur:
There are no commands defined in the "cashier" namespace.

The solution is to manually create the migration file and execute it:

Run this:
php artisan make:migration add_cashier_table_fields
And then, in the created empty file, add this:

[code]

<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AddCashierTableFields extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        //

         Schema::table('users', function ($table) {
            $table->string('stripe_id')->nullable();
            $table->string('card_brand')->nullable();
            $table->string('card_last_four')->nullable();
            $table->timestamp('trial_ends_at')->nullable();
        });
        Schema::create('subscriptions', function ($table) {
            $table->increments('id');
            $table->integer('user_id');
            $table->string('name');
            $table->string('stripe_id');
            $table->string('stripe_plan');
            $table->integer('quantity');
            $table->timestamp('trial_ends_at')->nullable();
            $table->timestamp('ends_at')->nullable();
            $table->timestamps();
        });
     
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        //
    }
}


[/code]

Now, you can execute the command:
php artisan migrate


Original solution is here:
http://itsolutionstuff.com/post/how-to-solve-there-are-no-commands-defined-in-the-cashier-namespace-in-laravel-5example.html

No comments:

Post a Comment

PSR-1 and PSR-2 coding standards for PHP

Visual aspects of code play a significant role in raising or drowning developer's productivity. In case that there's too much clutte...