📜  tinker colourful - PHP (1)

📅  最后修改于: 2023-12-03 14:47:59.373000             🧑  作者: Mango

Tinker Colourful - PHP

Tinker Colourful is a package for the Laravel framework that enhances the Tinker console command by adding syntax highlighting and code formatting. It makes it easier and more pleasant to work with the Tinker console, which is a powerful tool for debugging and experimenting with your application during development.

Installation

To install Tinker Colourful, you need to have Laravel already installed. You can then install the package via Composer:

composer require marquine/tinker-colourful

Once installed, the package will automatically register itself with Laravel, and you can start using it right away.

Usage

To use Tinker Colourful, simply run the Tinker command as usual:

php artisan tinker

You should now see a colourful and formatted console prompt, ready for you to start typing in PHP code:

>>> $name = 'John';
=> "John"
>>> echo "Hello, $name!";
Hello, John!

Tinker Colourful also adds syntax highlighting to your code, making it easier to read and understand. Here's an example of what a Tinker session might look like with Tinker Colourful enabled:

>>> $users = App\Models\User::all();
=> Illuminate\Database\Eloquent\Collection {#4634
     all: [
       App\Models\User {#4633
         id: 1,
         name: "John Doe",
         email: "johndoe@example.com",
         created_at: "2022-01-01 00:00:00",
         updated_at: "2022-01-02 00:00:00",
       },
       App\Models\User {#4632
         id: 2,
         name: "Jane Doe",
         email: "janedoe@example.com",
         created_at: "2022-01-01 00:00:00",
         updated_at: "2022-01-02 00:00:00",
       },
     ],
   }
>>> $user = $users->first();
=> App\Models\User {#4633
     id: 1,
     name: "John Doe",
     email: "johndoe@example.com",
     created_at: "2022-01-01 00:00:00",
     updated_at: "2022-01-02 00:00:00",
   }
>>> $user->name = 'James';
=> "James"
>>> $user->save();
=> true

As you can see, Tinker Colourful makes it easy to explore your application data and experiment with code, all from within the comfort of your console.

Conclusion

Tinker Colourful is a great package for Laravel developers who want to make their Tinker console sessions more enjoyable and productive. With syntax highlighting and code formatting, Tinker Colourful makes it easy to explore your application data and experiment with code, all from within the comfort of your console. Install it today and see for yourself!