Powerful REPL for the Laravel framework.

Overview

Logo Laravel Tinker

Build Status Total Downloads Latest Stable Version License

Introduction

Laravel Tinker is a powerful REPL for the Laravel framework.

Official Documentation

Documentation for Tinker can be found on the Laravel website.

Contributing

Thank you for considering contributing to Tinker! The contribution guide can be found in the Laravel documentation.

Code of Conduct

In order to ensure that the Laravel community is welcoming to all, please review and abide by the Code of Conduct.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

License

Laravel Tinker is open-sourced software licensed under the MIT license.

Comments
  • [2.x] Forward input options to psysh

    [2.x] Forward input options to psysh

    This PR forwards things like --no-ansi and -vv to psysh in the proper way, instead of ignoring them. Once this PR is merged, we can tag tinker v2.4.0.

    // cc @bobthecow

    opened by GrahamCampbell 19
  • Tinker lost colors

    Tinker lost colors

    • Tinker Version: 2.6.1
    • Laravel Version: 8.47.0
    • PHP Version: 8.0.7
    • Psy Shell: v0.10.8
    • Database Driver & Version:

    Description:

    Tinker is not using colors, all the text is white only, this issue happened when I installed a latest version of Laravel ( 8.47.0 ), I went to try some oldest versions of Laravel ( 8.46.0 and older ) tinker worked fine, text was colored fine, what should we do?

    Steps To Reproduce The Issue:

    It happens whenever we create a fresh Laravel project with composer

    composer create-project laravel/laravel .
    

    Samples

    cmd

    cmder

    needs more info 
    opened by Jervi-sir 18
  • PendingDispatch never dispatches if not assigned to a variable in Tinker

    PendingDispatch never dispatches if not assigned to a variable in Tinker

    This inconsistency took me a while to wrap my head around.

    >>> dispatch(new App\Jobs\TestJob)
    => Illuminate\Foundation\Bus\PendingDispatch {#1328}
    >>> exit
    

    Expected: PendingDispatch is dispatched when the object is destructed. Actual: Doesn't dispatch.

    >>> $pending = dispatch(new App\Jobs\TestJob)
    => Illuminate\Foundation\Bus\PendingDispatch {#1328}
    >>> exit
    

    This will dispatch.

    opened by mortenscheel 14
  • Should psy/psysh be require-dev?

    Should psy/psysh be require-dev?

    I'm probably biased due to my current situation, and/or don't fully understand composer with --production.

    I am trying to get my Laravel Spark application ready for production in a secure environment. Psy/psysh came up with a security issue after doing composer install --production on the project to prepare it for a security audit. I am trying to think of a use case for tinker to be used in production, and it would seem (to me anyway) that psy/psysh would be better suited to require-dev.

    Am I misunderstanding how composer works? Or would it make sense to move psy/psysh to require-dev?

    opened by phpguru 13
  • mkdir(): Permission denied

    mkdir(): Permission denied

    I'm having this error on latest Tinker and Laravel, when attempting to call artisan tinker.

    In Configuration.php line 352:
                                  
      [ErrorException]            
      mkdir(): Permission denied
    

    After some investigations it turned out that Psysh is trying to mkdir /run/user/0/psysh, which is not accessible.

    ~~Possibly related to #33~~

    opened by ingria 12
  • Suggestion: Multiple line support

    Suggestion: Multiple line support

    It would be fantastic if tinker supported multiple line statements... because then you could just cut and paste from your code rather than having to remove newline chars before pasting... for example rather than this:

    $d=DeviceCamera::with(['device'=>function($query){$query->select('devices.id as device_id', 'name as camera_name', 'slug as webcam_name')->groupBy('devices.id');},'device.device'=>function($query){$query->select('id','id as camera_id', 'camera_lens_type_id', 'settings',DB::raw("cast(settings->>'viewport_order' as int) as viewport_order"))->groupBy('id');},'deployments'=>function($query){$query->select('deployments.id as deployment_id','vessel_id')->groupBy('vessel_id')->groupBy('deployments.id');},'videos'=>function($query){$query->select('videos.id as video_id','server_id as vid_server_id',DB::raw("max(video_duration) as video_duration"),DB::raw('max(size) as size'),DB::raw('min(video_start_timestamp) as video_start_timestamp'),DB::raw('max(video_end_timestamp) as video_end_timestamp'),DB::raw('(array_agg(video_path))[1] as video_path'),'video_name')->groupBy('server_id')->groupBy('video_name');},'videos.server.device'=>function($query){$query->select('id as server_id',DB::raw("(array_agg(settings->>'fqdn'))[1] as fqdn"),DB::raw("(array_agg(settings->>'rtmp_path'))[1] as rtmp_path"));}])->get();
    

    I could have this

    $d = DeviceCamera::with([
        'device'  => function ($query) {
            $query->select(
                'devices.id as device_id', 'name as camera_name', 'slug as webcam_name'
            )->groupBy('devices.id');
        },
        'device.device' => function ($query) {
            $query->select(
                'id', 'id as camera_id', 'camera_lens_type_id', 'settings',
                DB::raw("cast(settings->>'viewport_order' as int) as viewport_order")
            )->groupBy('id');
        },
        'deployments' => function ($query) {
            $query->select(
                'deployments.id as deployment_id', 'vessel_id'
            )->groupBy('vessel_id')->groupBy('deployments.id');
        },
        'videos' => function ($query) {
            $query->select(
                'videos.id as video_id',
                'server_id as vid_server_id',
                DB::raw("max(video_duration) as video_duration"),
                DB::raw('max(size) as size'),
                DB::raw('min(video_start_timestamp) as video_start_timestamp'),
                DB::raw('max(video_end_timestamp) as video_end_timestamp'),
                DB::raw('(array_agg(video_path))[1] as video_path'),
                'video_name'
            )->groupBy('server_id')->groupBy('video_name');
        },
        'videos.server.device' => function ($query) {
            $query->select(
                'id as server_id',
                DB::raw("(array_agg(settings->>'fqdn'))[1] as fqdn"),
                DB::raw("(array_agg(settings->>'rtmp_path'))[1] as rtmp_path")
            );
        }])->get();
    
    opened by securit 11
  • Not working after upgrade to PHP 7.3.0

    Not working after upgrade to PHP 7.3.0

    • Laravel Version: 5.7.16
    • PHP Version: 7.3.0

    Please advise if this is a PsyShell bug, in which case I will file this issue at their repo.

    After upgrading PHP to 7.3.0 - latest version (and Xdebug to 2.7.0beta1 latest version compatible with PHP 7.3, in case it matters), tinker is no longer working. It launches correctly but I after I input a command it just exits with no error, nothing written to log file and status code 0.

    bug 
    opened by dciancu 10
  • Command

    Command "tinker" is not defined.

    Using Laravel Framework 5.4.23

    and

    name     : laravel/tinker
    descrip. : Powerful REPL for the Laravel framework.
    keywords : REPL, Tinker, laravel, psysh
    versions : * v1.0.0
    type     : library
    license  : MIT License (MIT) (OSI approved) https://spdx.org/licenses/MIT.html#licenseText
    source   : [git] https://github.com/laravel/tinker.git 3d5b675b55b24ccbf86395964042dbe061d5a965
    dist     : [zip] https://api.github.com/repos/laravel/tinker/zipball/3d5b675b55b24ccbf86395964042dbe061d5a965 3d5b675b55b24ccbf86395964042dbe061d5a965
    names    : laravel/tinker
    
    autoload
    psr-4
    Laravel\Tinker\ => src/
    
    requires
    illuminate/console ~5.1
    illuminate/contracts ~5.1
    illuminate/support ~5.1
    php >=5.5.9
    psy/psysh 0.7.*|0.8.*
    symfony/var-dumper ~3.0
    
    requires (dev)
    phpunit/phpunit ~4.0|~5.0
    
    suggests
    illuminate/database The Illuminate Database package (~5.1).
    

    when i do php artisan tinker as described on Repo's README.md file i got this error:

    [Symfony\Component\Console\Exception\CommandNotFoundException]
      Command "tinker" is not defined.
    

    i tried this on an empty project from scratch and tinker is working - not on my current project

    opened by PaoloFalomo 10
  • [2.x] Added new 'tinker.after-loop'-event

    [2.x] Added new 'tinker.after-loop'-event

    This PR adds a new 'tinker.after-loop' event, that gets fired after each execution of a command in the tinker shell while.

    Example

    If this gets merged, you could add this snippet to the boot method of your AppServiceProvider:

    \Illuminate\Support\Facades\Event::listen('tinker.after-loop', function () {
        echo 'You just executed something through tinker!' . PHP_EOL;
    });
    

    and the following output would be generated during a tinker session:

    » php artisan tinker
    Psy Shell v0.10.3 (PHP 7.3.11-0ubuntu0.19.10.3 — cli) by Justin Hileman
    >>> echo 'Hi GitHub' . PHP_EOL
    Hi GitHub
    You just executed something through tinker!
    >>> echo 'Another one!' . PHP_EOL
    Another one!
    You just executed something through tinker!
    >>>
    

    Motivation

    This enables third-parties to react to commands executed during tinker sessions. The concrete example that motivated this PR was Laravels telescope package. Executed queries, logs or model-events will not be recorded by telescope, as the application will not shut down while inside the tinker-loop. As an example that can be used for replication (executed in a fresh Laravel application with telescope installed):

    » php artisan tinker
    Psy Shell v0.9.12 (PHP 7.3.11-0ubuntu0.19.10.3 — cli) by Justin Hileman
    >>> App\User::create(['email' => '[email protected]', 'name' => 'I will not be recorded', 'password' => 'password']);
    => App\User {#3133
         email: "[email protected]",
         name: "I will not be recorded",
         updated_at: "2020-04-10 11:49:55",
         created_at: "2020-04-10 11:49:55",
         id: 99,
       }
    

    After you close the shell and navigate to /telescope/models, there is no entry recorded, as the ListensForStorageOpportunities-trait only handles the termination of the app and worker loops . This caused confusion in the past and could be fixed through the event implemented in this PR.

    Implementation

    Psy\Shell has an array of $loopListeners that listen for certain lifecycle events of the shell.

    These are implementations of the Psy\ExecutionLoop\Listener-interface and can not be modified, once an instance of Psy\Shell was constructed. They are set initially to whatever getDefaultLoopListeners() returns. For this reason, I created a new Laravel\Tinker\Shell extends Psy\Shell, overwrites the getDefaultLoopListeners()-method and adds another Listener. This Laravel\Tinker\Shell\Listener\TinkerEventEmitter-Listener then publishes the 'tinker.after-loop' event in its afterLoop-method, that gets called by Psy\Shell::afterLoop.

    The only modification to the existing Code is, that the TinkerCommand now needs to construct a TinkerShell instead of the standard Psy\Shell.

    Notes

    • I am not sure how I should add tests for this, as I did not found any existing tests that handle comparable situations. If tests are reqiured, it would be nice if someone could guide me in the right direction.
    • I used the event-helper inside the TinkerEventEmitter::afterLoop-method. If this is discouraged I will change it to use $this->app['events']->dispatch or something like that.

    If this gets merged, I would happily open another PR for telescope that makes the ListensForStorageOpportunities-trait also handle the 'tinker.after-loop'-event and thereby make it work more reliably with tinker.

    opened by NiclasvanEyk 9
  • Tinker does not fully respect -q and -n flags

    Tinker does not fully respect -q and -n flags

    • Tinker Version: 1.0.8
    • PHP Version: 7.1.19

    Description:

    Tinker with either the -q (quiet) or the -n (no interaction) does not fully respect these options. Use case is an include file that echos stuff as part of a build process, but it cannot be run headless.

    Steps To Reproduce:

    > php artisan tinker -q prints prompt >>> and the Exit: Goodbye. message.

    > php artisan tinker -n waits for interaction before exiting.

    File hello_world.php:

    <?php echo('Hello world!');
    

    > php artisan tinker -qn hello_world.php pauses until exit is typed in shell.

    bug 
    opened by aksonnic 9
  • Unexpected? behaviour dispatching to queues.

    Unexpected? behaviour dispatching to queues.

    Found some unexpected behaviour when dispatching jobs within tinker - namely jobs are dispatched the loop after you call them.

    I don’t know enough about queues (or tinker!) to know why.

    Psy Shell v0.8.11 (PHP 7.1.8 — cli) by Justin Hileman
    >>> App\Jobs\TestJob::dispatch(1);
    => Illuminate\Foundation\Bus\PendingDispatch {#831}
    >>> App\Jobs\ TestJob::dispatch(2);
    string(23) "TestJob(1) actually queued"
    => Illuminate\Foundation\Bus\PendingDispatch {#825}
    >>> App\Jobs\ TestJob::dispatch(3);
    string(23) "TestJob(2) actually queued"
    => Illuminate\Foundation\Bus\PendingDispatch {#834}
    >>> App\Jobs\ TestJob::dispatch(4);
    string(23) "TestJob(3) actually queued"
    => Illuminate\Foundation\Bus\PendingDispatch {#846}
    >>> $nop = true
    => true
    >>> 3
    => 3
    >>> sleep(1)
    => 0
    >>> exit
    string(23) "TestJob(4) actually queued"
    Exit:  Goodbye.
    

    The dispatching of jobs is delayed, and if you exit from tinker right after a dispatch() then the job (usually!) isn’t dispatched. (except it was in the test above!)

    It's the same in Laravel 5.4 and 5.5.

    opened by liefie 9
Releases(v2.7.3)
Powerful Unsplash package for Laravel

Powerful Unsplash package for Laravel Provides a fluent api to use the Unsplash within Larvel applications. Use public actions or store images directl

null 54 Dec 25, 2022
A powerful form builder, for Laravel and other frameworks (stand-alone too)

Former A Laravelish way to create and format forms Former outputs form elements in HTML compatible with your favorite CSS framework (Bootstrap and Fou

null 1.3k Dec 22, 2022
Provides a powerful error response system for Laravel

Laravel Exceptions Laravel Exceptions was created by, and is maintained by Graham Campbell, and provides a powerful error response system for both dev

Graham Campbell 571 Jan 31, 2022
🍪 Powerful wrapper for improved cookie integration on Laravel

?? Powerful wrapper for improved cookie integration on Laravel

Attla 1 Jul 16, 2022
The fastest way to make a powerful JSON:API compatible Rest API with Laravel.

The first fully customizable Laravel JSON:API builder. "CRUD" and protect your resources with 0 (zero) extra line of code. Installation You can instal

BinarCode 288 Aug 8, 2022
🔔 Flasher is a powerful and flexible flash notification system for PHP, Laravel, Symfony

A powerful and flexible flash notifications system for PHP, Laravel, Symfony ?? PHP Flasher helps you to add flash notifications to your PHP projects.

PHP Flasher 158 Jan 4, 2023
Laravel is accessible, powerful, and provides tools required for large, robust applications.

Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be trul

Web & Mobile | eCommerce | Full-Stack Developer 4 Nov 24, 2022
Extend Kirby’s templates with a powerful layout system

Kirby Layouts plugin This plugin extends Kirby’s templates with a powerful layout system. Installation Download Download and copy this repository to /

Kirby 3 39 Dec 28, 2022
HydePHP - Elegant and Powerful Static App Builder

HydePHP - Elegant and Powerful Static App Builder Make static websites, blogs, and documentation pages with the tools you already know and love. About

HydePHP 31 Dec 29, 2022
List of 77 languages for Laravel Framework 4, 5, 6, 7 and 8, Laravel Jetstream , Laravel Fortify, Laravel Breeze, Laravel Cashier, Laravel Nova and Laravel Spark.

Laravel Lang In this repository, you can find the lang files for the Laravel Framework 4/5/6/7/8, Laravel Jetstream , Laravel Fortify, Laravel Cashier

Laravel Lang 6.9k Jan 2, 2023
Framework - 🙃 Phony. Real-like Fake Data Generation Framework

?? Framework This repository contains the ?? Phony Framework. ?? Start generating fake data with ?? Phony Framework, visit the main Phony Repository.

Phonyland 5 Oct 31, 2022
User to Team associations with invitation system for the Laravel 5 Framework

Teamwork This package supports Laravel 6 and above. Teamwork is the fastest and easiest method to add a User / Team association with Invites to your L

Marcel Pociot 983 Jan 2, 2023
A full-stack framework for Laravel that takes the pain out of building dynamic UIs.

A full-stack framework for Laravel that takes the pain out of building dynamic UIs.

Livewire 17.7k Jan 1, 2023
Your users do not always report errors, LaraBug does. LaraBug is a simple to use and implement error tracker built for the Laravel framework.

Your users do not always report errors, LaraBug does. LaraBug is a simple to use and implement error tracker built for the Laravel framework. This rep

LaraBug 197 Dec 9, 2022
JSON-RPC 2.0 API server for @Laravel framework

Sajya is an open-source project aiming to implement the JSON-RPC 2.0 server specification for the Laravel quickly.

Sajya 179 Dec 29, 2022
Stapler-based file upload package for the Laravel framework.

laravel-stapler Laravel-Stapler is a Stapler-based file upload package for the Laravel framework. It provides a full set of Laravel commands, a migrat

Code Sleeve 565 Dec 9, 2022
SSLCommerz Payment gateway library for Laravel framework

SSLCommerz SSLCommerz Payment gateway library for Laravel framework. Official documentation is here. install composer require sam-asif/sslcommerz Pro

Md. Asif Iqbal 1 Oct 28, 2021
OpenShift QuickStart - Laravel 5.0 Framework

Laravel 5.0 on OpenShift Laravel is a free, open source PHP web application framework, designed for the development of model–view–controller (MVC) web

Jacob Lucky 52 Nov 21, 2022
Extend Laravel PHP framework to make working with Aiven databases simpler

Aiven Commands for Laravel ✨ Add some Aiven magic to your Laravel project ✨ This Laravel package provides some aiven commands for artisan to help with

Aiven 8 Aug 19, 2022