⛔️ Laravel Tinx is archived and no longer maintained.

Overview

⛔️ Laravel Tinx (Deprecated)

No Maintenance Intended

Laravel Tinx was archived on 12th December 2019 and is no longer maintained.

Looking for a reloadable version of Laravel Tinker?

Save the following script as tinx.sh to your project root directory:

#!/bin/sh
while true; do php artisan tinker; done

Run the script to launch a reloadable version of Tinker:

$ . tinx.sh

While your Tinker session is running, press:

  • Ctrl + D from an empty prompt to reload your session
  • Ctrl + C to exit your session

Can't see newly created classes in Tinker?

Exit your Tinker session and run:

$ composer dump -o

Thanks for loving Laravel, and thanks for digging Tinx.

Happy coding!

🤓 👋


Laravel Tinx

Laravel Tinker, re()loaded.

Reload your session from inside Tinker, plus magic shortcuts for first(), find(), where(), and more!

Contents

Installation

To install Tinx, simply require it via Composer:

composer require --dev ajthinking/tinx

If using Laravel <=5.4, register Tinx's service provider in config/app.php (Laravel >=5.5 does this automatically):

<?php

// 'config/app.php'

return [
    // etc…
    'providers' => [
        // etc…
        Ajthinking\Tinx\TinxServiceProvider::class,
        // etc…
    ],
    // etc…
];

Usage

From the command line, instead of running php artisan tinker, run:

php artisan tinx

Reload your Tinker session

To reboot your current session, simply call:

re()

This will allow you to immediately test out your application's code changes.

Aliases: reboot(), reload(), restart().

To regenerate Composer's optimized autoload files before rebooting your current session, call:

reo()

Calling reo() simply runs composer dump -o before re(), ensuring any new classes added to your codebase since starting Tinx are automatically aliasable/resolvable by Laravel Tinker.

Magic models

Tinx sniffs your models and prepares the following shortcuts:

Example Shortcut Equals
$u App\User::first()
$u_ App\User::latest()->first()
$c App\Models\Car::first()
u(3) App\User::find(3)
u("gmail") Where "%gmail%" is found in any column.
u("mail", "[email protected]") App\User::where("mail", "[email protected]")->get()
u("id", ">", 0) App\User::where("id", ">", 0)->get()
u() "App\User"
u()::whereRaw(...) App\User::whereRaw(...) // Note: >= PHP 7.0 only

Naming strategy

Tinx calculates shortcut names via the implementation defined by your strategy config value.

Lets say you have two models: Car and Crocodile.

If your naming strategy was set to pascal (default), Tinx would define the following shortcuts in your session:

  • Car: $c, $c_, c()
  • Crocodile: $cr, $cr_, cr()

Names

The shortcuts defined for your session will display when Tinx loads and on subsequent reloads.

To see your shortcuts at any time during your session, run:

names()

Your shortcuts will initially display only if your session satisfies the names_table_limit config value.

To filter the shortcuts returned by names(), simply pass your filter terms like so:

names('car', 'user')

Fast factories

Shortcut methods are a great way to create factory models fast.

// Instead of this…
factory(App\User::class)->create()

// …try substituting a shortcut method, like this:
factory(u())->create()

When tinkering, every keystroke counts!

Configuration

Tinx contains a number of helpful configuration options.

To personalise your Tinx installation, publish its config file by running:

php artisan vendor:publish --provider=Ajthinking\\Tinx\\TinxServiceProvider --force

Once published, edit config/tinx.php where appropriate to suit your needs:

<?php

// 'config/tinx.php'

return [

    /**
     * Base paths to search for models (paths ending in '*' search recursively).
     * */
    'model_paths' => [
        '/app',
        '/app/Models/*',
        // '/also/search/this/directory',
        // '/also/search/this/directory/recursively/*',
    ],

    /**
     * Only define these models (all other models will be ignored).
     * */
    'only' => [
        // 'App\OnlyThisModel',
        // 'App\AlsoOnlyThisModel',
    ],

    /**
     * Ignore these models.
     * */
    'except' => [
        // 'App\IgnoreThisModel',
        // 'App\AlsoIgnoreThisModel',
    ],

    /**
     * Model shortcut naming strategy (e.g. 'App\User' = '$u', '$u_', 'u()').
     * Supported values: 'pascal', 'shortestUnique'
     * */
    'strategy' => 'pascal',
    /**
     * Alternatively, you may pass a resolvable fully qualified class name
     * implementing 'Ajthinking\Tinx\Naming\Strategy'.
     * */
    // 'strategy' => App\CustomNamingStrategy::class,

    /**
     * Column name (e.g. 'id', 'created_at') used to determine last model shortcut (i.e. '$u_').
     * */
    'latest_column' => 'created_at',

    /**
     * If true, models without database tables will also have shortcuts defined.
     * */
    'tableless_models' => false,

    /**
     * Include these file(s) before starting tinker.
     * */
    'include' => [
        // '/include/this/file.php',
        // '/also/include/this/file.php',
    ],

    /**
     * Show the console 'Class/Shortcuts' table for up to this many model names, otherwise, hide it.
     * To always view the 'Class/Shortcuts' table regardless of the model name count,
     * pass a 'verbose' flag when booting Tinx (e.g. "php artisan tinx -v"),
     * or set this value to '-1'.
     * */
    'names_table_limit' => 10,

];

Contributing

Please post issues and send PRs.

License

MIT

Comments
  • command

    command "tinx" is not defined

    Hi,

    I followed the documentation to install and run the tinx; but I am getting an exception Please refer to the below screenshot. I have tried this on laravel 5.4.27 and lumen 5.4, both having tinker pre-installed.

    image

    Thanks.

    opened by JatinSethi 13
  • Model without an associated table

    Model without an associated table

    In the case of models with no associated table, an error is shown when running tinx. It does allow the tinx session to continue, but is a little annoying to see the error each time. Would you be open to a simple config addition for ignored models: e.g.:

    return [
        'namespaces_and_paths' => [
            'App' => '/app',
            'App\Models' => '/app/Models',
        ],
        'ignore' => [
            'App\Models\ModelWithoutTable',
        ],
    
        'strategy' => 'shortestUnique',
    ];
    

    Then in Model.php, along with the check for an abstract class, we could also check to see if the model is ignored.

    Another idea is to just check for table existence behind the scenes and ignore any models without tables internally.

    Thoughts?

    opened by devcircus 13
  • re() doesn't reload files

    re() doesn't reload files

    I'm currently doing some test driven development on my MacBook and was looking for some way to refresh artisan tinker. Tinx looks like the solution, but it does not reload the files like I hoped it would. I got an error saying I needed to add an attribute to the fillable array, so I added it and hoped that a simple re() would reload the file, but it keeps throwing the same error, until I exit Tinx and start it again.

    Am I using Tinx wrong, or could there be an issue?

    I'm on Laravel 5.6, PHP 7.1.10 and here is my composer.json:

    "require": {
        "php": ">=7.1.3",
        "ajthinking/tinx": "^2.0",
        "doctrine/dbal": "^2.6",
        "fideloper/proxy": "~4.0",
        "laravel/framework": "5.6.*",
        "laravel/tinker": "~1.0"
    },
    "require-dev": {
        "filp/whoops": "~2.0",
        "nunomaduro/collision": "~1.1",
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "~1.0",
        "phpunit/phpunit": "~7.0",
        "barryvdh/laravel-debugbar": "^3.1",
        "barryvdh/laravel-ide-helper": "^2.4",
        "arcanedev/log-viewer": "^4.4"
    },
    
    opened by SerendipityNL 12
  • Custom shortcut

    Custom shortcut

    First of all, this is brilliant! I would love to try this and I'm very optimistic that I'll use this a lot more than I'll use tinker!

    Second, custom shortcut. Add methods to add shortcuts that we want to a service provider and boom! I don't really know what I'll make, maybe to create data faster? No idea yet. But really the possibility to do this would excite lots of people! Extendable tinker, that you can plug custom functions, default variable, custom classes, and more! How cool is that?

    Great job for this package!

    opened by imam 12
  • Useful - tinker required

    Useful - tinker required

    I like it! The package has very good improvements to tinker.

    2 things I noticed:

    1. I think you should put laravel/tinker as requirement. It might be obvious but at first I thought this is a replacement and just replaced laravel/tinker with your package. Didn't read much before so it might be just my problem ;)

    2. In App\Models I have two models User and Userlog. In tinx I seem to only can use $userl no variable for $user which would be more important.. Did I miss smth? I think I have read the complete readme now :)

    $u PHP Notice: Undefined variable: u on line 1 $us PHP Notice: Undefined variable: us on line 1 $user PHP Notice: Undefined variable: user on line 1 $userl => App\Models\Userlog {#1531

    enhancement help wanted good first issue hacktoberfest 
    opened by wgmv 10
  • Permission Denied

    Permission Denied

    Hi, Some times I get this error without touching artisan tinx:

    file_put_contents(/var/www/html/---/----/storage/tinx/.gitignore): failed to open stream: Permission denied
    

    It is so weird and I have no idea what's going on, any help will be appreciated.

    opened by apair 9
  • Call to undefined method League\Flysystem\Filesystem::path

    Call to undefined method League\Flysystem\Filesystem::path

    I'm on Laravel 5.3 and I can't see a path method in the version of Flysystem installed in /vendor

    Is it supported? I added the service provider Ajthinking\Tinx\TinxServiceProvider::class to config/app.php so it found the command.

    $ php artisan tinx
    Tinx - something awesome is about to happen.
    
    [BadMethodCallException]                                    
    Call to undefined method League\Flysystem\Filesystem::path 
    
    opened by joevallender 8
  • [SUGGESTION] Add ability to combine re() with code following it

    [SUGGESTION] Add ability to combine re() with code following it

    To even further speed up local development, it would be great if this could work:

    >>> re(); $u->count();
    

    As of right now, anything after re() isn't picked up for the next session:

    Reloading your tinker session...
    47 models found (to view shortcuts on boot, see: config/tinx.php > names_table_limit).
    Hint: Filter your model shortcuts by passing terms to "names()" e.g. "names('User', 'Team')" etc.
    Psy Shell v0.8.17 (PHP 7.1.12-3+ubuntu14.04.1+deb.sury.org+1 — cli) by Justin Hileman
    >>> 
    
    enhancement 
    opened by mfn 6
  • Ownership

    Ownership

    @furey Its been tons of fun working with you on the tinx repo and to see all improvements. I hope you will accept ownership of this repo as a christmas gift.

    Dont worry about the namespaces, Ill leave packagist up and running and it should be business as usual for the users? And github will handle forwarding of requests attempting to access ajthinking/tinx. Happy holidays :D

    opened by ajthinking 6
  • Flare config is not loaded

    Flare config is not loaded

    Laravel 6.0.3, just upgraded from 5.6 Tinx v2.4.0, using default tinx.php config file (in [project]/config folder)

    If I run php artisan tinker and execute the command config( 'flare' ) it returns

    >>> config( 'flare' )
    => [
         "key" => null,
         "reporting" => [
           "anonymize_ips" => true,
           "collect_git_information" => true,
           "report_queries" => true,
           "report_query_bindings" => true,
           "report_view_data" => true,
         ],
       ]
    

    However, if I do the same in Tinx, I get:

    >>> config( 'flare' )
    => null
    

    Somehow, the configuration in vendors/facade/ignition/config/flare.php is not loaded in Tinx, while it loads in Tinker.

    Due to this missing config, I get the error TypeError: Argument 2 passed to Facade/Ignition/QueryRecorder/Query::fromQueryExecutedEvent() must be of the type bool, null given, called in /vendor/facade/ignition/src/QueryRecorder/QueryRecorder.php on line 32 when running a query in Tinx.

    opened by JBtje 5
  • re() doesn't reload observers code

    re() doesn't reload observers code

    Hello,

    First of all, I'm loving tinx!

    But now comes the problem, I'm developing an observer and I'm testing it on tinx, it happens that when I change something in observer and I use the re();

    My change does not happen in tinx, I need to give an exit and run it all over again to make it work :(

    Is there any limitation for observers?

    Thank you.

    help wanted 
    opened by anderson-flores 5
Releases(vEOL)
  • vEOL(Dec 11, 2019)

  • v2.6.0(Oct 3, 2019)

  • v2.5.0(Sep 24, 2019)

  • v2.4.1(Sep 24, 2019)

  • v2.4.0(Aug 29, 2019)

  • v2.3.1(Mar 22, 2019)

  • v2.3.0(Mar 22, 2019)

  • v2.2.0(Mar 19, 2019)

    v2.2.0 adds a reo() function to regenerate Composer's optimized autoload files before running re(), ensuring any new classes added to a codebase since starting Tinx are automatically aliasable/resolvable by Laravel Tinker (see #53).

    Source code(tar.gz)
    Source code(zip)
  • v2.1.9(Feb 12, 2019)

  • v2.1.8(Feb 5, 2019)

  • v2.1.7(Aug 28, 2018)

  • v2.1.6(Apr 11, 2018)

  • v2.1.5(Mar 19, 2018)

  • v2.1.4(Mar 19, 2018)

    v2.1.4 is exactly the same as v2.1.3 (created v2.1.3 via SourceTree instead of GitHub, without GPG signing, and in an attempt to fix, accidentally created this patch bump release).

    Source code(tar.gz)
    Source code(zip)
  • v2.1.3(Mar 19, 2018)

  • v2.1.2(Mar 16, 2018)

  • v2.1.1(Feb 20, 2018)

  • v2.1.0(Feb 20, 2018)

  • v2.0.7(Jan 13, 2018)

  • v2.0.6(Dec 26, 2017)

  • v2.0.5(Dec 8, 2017)

    v2.0.5 adds console messages when booting for Tinx applications where the total number of found model classes is greater than their config/tinx.php > names_table_limit value.

    For example, if an application's names_table_limit was set to 10, a user might see:

    screen shot 2017-12-08 at 4 33 56 pm Source code(tar.gz)
    Source code(zip)
  • v2.0.4(Dec 7, 2017)

    Laravel doesn't follow semver. So having ^5.x or >=5.x will mean that composer will install a future version even though that version breaks the package.

    Source code(tar.gz)
    Source code(zip)
  • v2.0.3(Dec 7, 2017)

    v2.0.3 patches a bug preventing PHP configurations with short_open_tag = On from rendering Tinx's includes.blade.php file correctly (the <? at the start of <?placeholder would throw a parse error).

    Source code(tar.gz)
    Source code(zip)
  • v2.0.2(Dec 3, 2017)

  • v2.0.1(Nov 26, 2017)

    v2.0.1 patches PHP 7.0 backwards incompatible syntax to support PHP 5.6.

    Note:

    If using PHP 5.6, Tinx shortcut function static methods (e.g. u()::first()) will fail:

    >>> u()::first()
    PHP Parse error: Syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM on line 1
    

    Instead, cache your shortcut function class in a variable and call your static methods against that:

    >>> $_u = u()
    => "App\User"
    >>> $_u::first()
    => App\User {#752
         id: "1",
         name: "test",
         email: "[email protected]",
         created_at: "2017-11-26 03:26:23",
         updated_at: "2017-11-26 03:26:23",
       }
    

    For more info, see: https://stackoverflow.com/q/38669459/1210490

    Source code(tar.gz)
    Source code(zip)
  • v2.0.0(Nov 14, 2017)

    v2.0.0 implements recursive model searching by changing namespaces_and_paths to model_paths in Tinx's config…

    <?php
    
    // 'config/tinx.php'
    
    return [
    
        /**
         * Base paths to search for models (paths ending in '*' search recursively).
         * */
        'model_paths' => [
            '/app',
            '/app/Models/*',
            // '/also/search/this/directory',
            // '/also/search/this/directory/recursively/*',
        ],
    
        // etc…
    
    ];
    

    …and then recursively searching paths ending in *.

    No more declaring namespaces – just pass an array of paths and Tinx detects them for you!

    Please ensure you've force published Tinx's config file first:

    php artisan vendor:publish --provider=Ajthinking\\Tinx\\TinxServiceProvider --force
    

    Note this is a breaking change hence the version 2.

    Source code(tar.gz)
    Source code(zip)
  • v1.0.1(Nov 13, 2017)

  • v1.0.0(Nov 12, 2017)

    • Added "pascal" naming strategy/tests (replaces "shortestUnique" as default) • Added console "Class/Shortcuts" table (replaces names(); filterable e.g. names('user')) • Added "illuminate/container:~5.2" dependency (supporting back to Laravel 5.2) • Significant architectural refactors • Update README (including GIF)

    Source code(tar.gz)
    Source code(zip)
  • v0.8.4(Nov 4, 2017)

  • v0.8.3(Oct 31, 2017)

    v0.8.3 loosens the exception check when trying to include class instances (was previously catching Illuminate\Database\QueryException; now simply catching Exception), catching and ignoring Throwable errors at the same time (e.g. models where query builder methods aren't defined i.e. class files that don't extend Illuminate\Database\Eloquent\Model).

    Source code(tar.gz)
    Source code(zip)
Owner
James Furey
Ask. Think. Conceive. Focus. Create. Design. Discuss. Develop. Break. Fix. Seed. Deploy. Study. Tweak. Measure. Refine. Track. Enhance. Engage. Enjoy.
James Furey
InfyOm Laravel Generator - API, Scaffold, Tests, CRUD Laravel Generator

InfyOm Laravel Generator Generate Admin Panels CRUDs and APIs in Minutes with tons of other features and customizations with 3 different themes. Read

InfyOmLabs (InfyOm Technologies) 3.5k Jan 1, 2023
A PHP-based sandboxing library with a full suite of configuration and validation options.

A full-scale PHP 5.4+ sandbox class that utilizes PHP-Parser to prevent sandboxed code from running unsafe code. It also utilizes FunctionParser to di

Corveda 192 Dec 10, 2022
:rocket: A Smart CRUD Generator For Laravel

Features Generate your models, views, controllers, routes and migrations just in a few clicks. Models visualization through a graph presentation (New

Houssain Amrani 891 Dec 23, 2022
Laravel IDE Helper

Laravel IDE Helper Generator Complete PHPDocs, directly from the source This package generates helper files that enable your IDE to provide accurate a

Barry vd. Heuvel 12.8k Dec 29, 2022
This package extends the core file generators that are included with Laravel 5

Extended Migration Generators for Laravel 6, 7 and 8 Easily define the migration schema right in your make:migration command. The new commands this pa

Laracasts 2.4k Dec 29, 2022
Laravel API Documentation Generator

Laravel API Documentation Generator Automatically generate your API documentation from your existing Laravel/Lumen/Dingo routes. php artisan apidoc:ge

Marcel Pociot 3.3k Dec 21, 2022
A cli tool for creating Laravel packages

Laravel Packager This package provides you with a simple tool to set up a new package and it will let you focus on the development of the package inst

JeroenG 1.3k Dec 22, 2022
A MySQL Workbench plugin which exports a Model to Laravel 5 Migrations

MySQL Workbench Export Laravel 5 Migrations Plugin A MySQL Workbench plugin that allows for exporting a model to Laravel 5 migrations that follow PSR-

Brandon Eckenrode 902 Jan 2, 2023
⚙️ A Laravel package to decompose your installed packages, their dependencies, your app & server environment

Introduction Laravel Decomposer decomposes and lists all the installed packages and their dependencies along with the Laravel & the Server environment

LUBUS 513 Dec 30, 2022
🍪 Write gorgeous documentation for your products using Markdown inside your Laravel app.

LaRecipe Write gorgeous documentations for your products using Markdown inside your Laravel app. LaRecipe ?? LaRecipe is simply a code-driven package

Saleem Hadad 2.1k Dec 29, 2022
Module Generator Composer Package For Laravel

Module Generator Installation You can install the package via composer: composer require teacoders/module-generator Run the command below to publish t

Tea Coders 21 Jan 8, 2022
Creates an 'artisan workflow:make' command to scaffold out a number of useful GitHub actions workflows for Laravel

Laravel workflow generator This creates a make:workflow artisan command to scaffold out a number of useful GitHub actions workflows for Laravel. Insta

Len Woodward 9 Jul 18, 2021
ARCHIVED

PHPExcel - DEAD PHPExcel last version, 1.8.1, was released in 2015. The project was officially deprecated in 2017 and permanently archived in 2019. Th

PHPOffice 11.5k Dec 30, 2022
Laravel Security was created by, and is maintained by Graham Campbell, and is a voku/anti-xss wrapper for Laravel, using graham-campbell/security-core

Laravel Security Laravel Security was created by, and is maintained by Graham Campbell, and is a voku/anti-xss wrapper for Laravel, using graham-campb

Graham Campbell 170 Nov 20, 2022
Laravel Flysystem was created by, and is maintained by Graham Campbell, and is a Flysystem bridge for Laravel.

Laravel Flysystem Laravel Flysystem was created by, and is maintained by Graham Campbell, and is a Flysystem bridge for Laravel. It utilises my Larave

Graham Campbell 492 Feb 4, 2022
Simple handler system used to power clients and servers in PHP (this project is no longer used in Guzzle 6+)

RingPHP Provides a simple API and specification that abstracts away the details of HTTP into a single PHP function. RingPHP be used to power HTTP clie

Guzzle 846 Dec 6, 2022
Until 2018, Backpack v3 used this Base package to offer admin authentication and a blank admin panel using AdminLTE. Backpack v4 no longer uses this package, they're now built-in - use Backpack/CRUD instead.

Note: This package is only used by Backpack v3. Starting with Backpack v4, everything this package does is included in Backpack/CRUD - one package to

Backpack for Laravel 845 Nov 29, 2022
A Laravel 4 CMS – WARNING: This project is no longer being developed because there are many good alternatives now.

This is the main larapress repository. Warning: This Application is under development and not yet production ready! Important Links Installation Contr

Martin Hettiger 155 Sep 27, 2022
This is the official place where Nemesysco's LVA7 and QA7 dockers will be hosted and maintained

LVA-Dockers This is the official place where Nemesysco's LVA7 and QA7 dockers will be hosted and maintained - It is still under construction! We are w

null 2 Feb 17, 2022
A python program to cut longer MP3 files (i.e. recordings of several songs) into the individual tracks.

I'm writing a python script to cut longer MP3 files (i.e. recordings of several songs) into the individual tracks called ReCut. So far there are two

Dönerspiess 1 Oct 27, 2021