Coder Social home page Coder Social logo

tinx's Introduction

👤

tinx's People

Contributors

ajthinking avatar astorm avatar brainmaniac avatar dallincoons avatar darin-sai avatar dylan-dpc avatar furey avatar ilcallo avatar matriphe avatar matthewtrask avatar mstnorris avatar naneri avatar rinze-smits avatar spelcaster avatar timrspratt avatar zedentox avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tinx's Issues

models in subfolder

Hey ajthinking,

nice job!

At the moment the names() command gives me an empty array [].

My models structure:
app
---- Models
--------Car
------------Door.php
------------Engine.php
--------Employee
------------Some.php
------------Model.php

Maybe this is not supported at the moment.
Can you make that configurable?

Thanks and again: nice job!

Shortcut gets 'undefined variable in Psy Shell'

Hello,

I've installed a fresh version of tinxz (^2.1) in a fresh Laravel (5.7.13) app and … TL;DR I've done this in the terminal:

~/Code/app master*
❯ a make:model Test
Model created successfully.

~/Code/app master*
❯ a tinx
Tinx – something awesome is about to happen.
+--------------+--------------+
| Class        | Shortcuts    |
+--------------+--------------+
| App\Test     | $t, $t_, t() |
| App\User     | $u, $u_, u() |
+--------------+--------------+
Psy Shell v0.9.9 (PHP 7.2.11 — cli) by Justin Hileman
>>> $t
PHP Notice:  Undefined variable: t in Psy Shell code on line 1
>>>

From my debugging I've checked that in the $names global variable the App\\Test is missing.

Psy Shell v0.9.9 (PHP 7.2.11 — cli) by Justin Hileman
>>> $names
=> [
     "App\User" => "u",
   ]
>>>

Any idea?

Class 'Arr' not found on start up

When starting tinx on Laravel 5.7.21 I'm greeted with a message saying:

root@3c1a41a39166:/app# php artisan tinx
Tinx – something awesome is about to happen.

   ErrorException  : Class 'Arr' not found (View: /app/vendor/ajthinking/tinx/resources/views/includes.blade.php)

  at /app/storage/framework/views/be5e1af9a1a729ea1878b73c6383511207e78a62.php:129
    125|  * For "first" variable, returns "::first()" if class DB table exists, otherwise "new" (if 'tableless_models' set to true).
    126|  * For "last" variable, returns "::latest()->first()" if class DB table exists, otherwise "new" (if 'tableless_models' set to true).
    127|  * */
    128| Arr::set($GLOBALS, 'tinx.names', <?php echo var_export($names);; ?>);
  > 129| $latestColumn = '<?php echo e(Arr::get($config, 'latest_column', 'created_at')); ?>';
    130| <?php $__currentLoopData = $names; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $class => $name): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
    131|     try {
    132|         $<?php echo $name; ?> = <?php echo $class; ?>::first() ?: app('<?php echo $class; ?>');
    133|         $<?php echo $name; ?>_ = <?php echo $class; ?>::latest($latestColumn)->first() ?: app('<?php echo $class; ?>');

  Exception trace:

  1   Illuminate\View\Engines\CompilerEngine::handleViewException(Object(Symfony\Component\Debug\Exception\FatalThrowableError))
      /app/vendor/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php:47

  2   Illuminate\View\Engines\PhpEngine::evaluatePath("/app/storage/framework/views/be5e1af9a1a729ea1878b73c6383511207e78a62.php", [Object(Illuminate\View\Factory), Object(Illuminate\Foundation\Application)])
      /app/vendor/laravel/framework/src/Illuminate/View/Engines/CompilerEngine.php:59

  Please use the argument -v to see more details.
root@3c1a41a39166:/app# php artisan --version
Laravel Framework 5.7.21

Adding the namespace to Arr on that line fixes the error. Evaluated code in is executed as if in a new file, so it doens't copy the namespace from the parent script.

re() doesn't reload changes in models located at app folder

version: 2.1.9

  1. install the latest tinx version and made no other changes.
  2. add two models - app/Models/User.php and app/Order.php.
  3. start php artisan tinx
  4. add to both models the following method:
public function test() {
    return 123;
}
  1. run re() in tinx shell
  2. running (new User())->test() results in 123 output
  3. running (new Order())->test() results in BadMethodCallException

Abstract Models

Hi,

My repo has a number or abstract models, causing Tinx to throw a fatal error on boot.

screen shot 2017-10-23 at 8 22 09 pm

screenshot

Would it be possible to simply ignore abstract classes?

Thanks for your hard work. Tinx is super cool!

😎🤙

Conflict with Facade/Ignition

Hey,
As I installed facade/ignition, Tinx did not work properly and it seems could not find models.
eg: I get this error for getting u() :

PHP Fatal error:  Call to undefined function u() in Psy Shell code on line 1

Laravel : 5.7.28
Tinx: 2.4.0

PS: I remove Ignition and Tinx works again

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

Reload does not reload files

Maybe I'm misunderstanding how Tinx is supposed to work, but I had assumed included files would automatically be reloaded. For example:

use App\Utils\GeoIP;
re()

$geo = new GeoIP();
PHP Fatal error:  Class 'GeoIP' not found in Psy Shell code on line 1

Is this a bug, or can Tinx not handle this case? Thanks!

Faker not being loaded.

It doesn't look like faker gets loaded in tinx.

>>> $faker = Faker\Factory::create();
results in
PHP Fatal error: Class 'Faker/Generator/Factory' not found in Psy Shell code on line 1

In tinker I can run

$faker = Faker\Factory::create();
$thumbnail = $faker->imageUrl(400,400, 'people');
$image =  Image::make($thumbnail);
$image->save(Storage::disk('local')->path('products'). 'testfile.jpeg');

This is particularly an issue because faker loads so many components.

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 

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?

Support use of Thinker V2.0.0

6 days ago a new version of Thinker, V2.0.0 was released.
Based on the release notes, it does not look that dramatically, but it should support Laravel 7

Tinx currently relies on ~1.0 so here my request for support of v2.0. I guess it should be a major release, since support for Laravel 5.x will be dropped with it.

re() doesn't reload route changes

Using re() doesn't reload changes to the route list. If you are using a UrlGenerator the generator still references the old routing list.

re() does not work properly in 0.6 - 0.8

Given:

class Skin extends Model
{
    public static $a = 123;
}

In Tinx:

s()::$a
// outputs 123
// * changes Skin.php code to 12345 *
re()
s()::$a
// still outputs 123!
\q
php artisan tinx
s()::$a
// outputs 12345

Just confirmed it works as intended in 0.5 but not in 0.6 (or 0.8)

PHP reserved keywords

Functions should not be named to reserved keywords.

$keywords = array('__halt_compiler', 'abstract', 'and', 'array', 'as', 'break', 'callable', 'case', 'catch', 'class', 'clone', 'const', 'continue', 'declare', 'default', 'die', 'do', 'echo', 'else', 'elseif', 'empty', 'enddeclare', 'endfor', 'endforeach', 'endif', 'endswitch', 'endwhile', 'eval', 'exit', 'extends', 'final', 'for', 'foreach', 'function', 'global', 'goto', 'if', 'implements', 'include', 'include_once', 'instanceof', 'insteadof', 'interface', 'isset', 'list', 'namespace', 'new', 'or', 'print', 'private', 'protected', 'public', 'require', 'require_once', 'return', 'static', 'switch', 'throw', 'trait', 'try', 'unset', 'use', 'var', 'while', 'xor');

$predefined_constants = array('__CLASS__', '__DIR__', '__FILE__', '__FUNCTION__', '__LINE__', '__METHOD__', '__NAMESPACE__', '__TRAIT__');

tinx not working

php artisan tinx doesn't work after fresh install with composer. I'm on Laravel 5.5

screen shot 2017-10-26 at 10 55 12 am

PDO::prepare(): send of 40 bytes failed with errno=32 Broken pipe

Following error appears occasionally after reloading session using re() :

Psy Shell v0.9.9 (PHP 7.2.10-0ubuntu0.18.04.1 — cli) by Justin Hileman
PHP Notice: PDO::prepare(): send of 40 bytes failed with errno=32 Broken pipe in /media/jay/New Volume1/current-learning/laravel/laracast -Eloquent Techniques/demoapp/vendor/laravel/framework/src/Illuminate/Database/Connection.php on line 326

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.

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!

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

Tinx does not remember command history

I really like the idea behind this but unfortunately without command history being unavailable it is a bit useless to me. Command history should be available per current "session", after reload and even after closing and re-opening. History available = you can browse it with up and down. Tinker has this and I rely on this.

Tinx does seem to offer something but it is... weird. I cannot really describe it. It offers me things I have not typed this session instead of the command directly above that I just typed manually. And maybe if I hit "up" about 10 times I get the actual command I just ran... if it is even available.

[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
>>> 

Cursor Navigation in prompt

Hi
I want to fork in this project to improve the cursor navigation in the tinx promp.
Actually commands like ctrl + arror_right and others produce annoying outputs in the prompt like ";5C" and etc..

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"
},

Method get does not exist

laravel 5.5.*

In Macroable.php line 74:

Method get does not exist. (View: /Users/comiru/Workspace/comiruAPI/vendor/ajthinking/tinx/resources/views/includes.blade.php)

In Macroable.php line 74:

Method get does not exist.

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.

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.

Docs: please add instructions for those who are on Laravel < 5.5

It is said, in the README.md, that the package supports Laravel 5.5's auto-discovery. This is good, but I think it would also be great to have a little bit of instructions (what service provider to add where) for those who are using earlier versions of Laravel.

Thank yo.

Lumen 5.3 "Class Illuminate\Foundation\Bootstrap\LoadConfiguration does not exist"

Since I don't have an config/app.php

I added

$app->register(Ajthinking\Tinx\TinxServiceProvider::class);

to my bootstrap/app.php

which registers the command

however I get the error message

[ReflectionException]
  Class Illuminate\Foundation\Bootstrap\LoadConfiguration does not exist

I don't have this class in this version of lumen, is it not supported?

Allow for where in magic functions

Add possibility to use where directly in the magic functions. Like

u("name", "Anders") // exact matches only!
u("id", ">", 3) // Three parameter version

Base name as class shortcut

I'm on a new Laravel installation and I would like to be able to call models by their base name, eg:
\App\Http\Models\Car -> Car
Neither of the provided strategies seem to work. I tried implementing a new one, very straightforward:

<?php

namespace Ajthinking\Tinx\Naming;

class BaseNameStrategy implements Strategy
{
    /**
     * @param \Illuminate\Support\Collection $models
     * @return void
     * */
    public function __construct($models)
    {
        $this->models = $models;
    }

    /**
     * @return array
     * */
    public function getNames()
    {
        $names = [];

        foreach ($this->models as $model) {
            $names[$model->fullClassName] = class_basename($model->fullClassName);
        }

        return $names;
    }
}

and I placed it alongside PascalStrategy.php and ShortestUniqueStrategy.php, but this doesn't seem to work.

Can it be done? Any suggestions?

Call to undefined function Ajthinking/Tinx/Console/str_plural()

When i add new path to model_paths, tinx throws
Tinx – something awesome is about to happen.
Psy Shell v0.9.9 (PHP 7.2.22 — cli) by Justin Hileman
PHP Error: Call to undefined function Ajthinking/Tinx/Console/str_plural() in /Users/vitaly/code/ycms-client-panel/vendor/ajthinking/tinx/src/Console/NamesTable.php on line 148

Running php artisan tinx prints the banner and exits.

Running on Laravel 5.7.25, Php 7.3.3.

✔ ~/workspace/project [branch L|✚ 3…3⚑ 1] 
08:52 $ php artisan tinx
Tinx – something awesome is about to happen.
Psy Shell v0.9.9 (PHP 7.3.3 — cli) by Justin Hileman
✔ ~/workspace/project [branch L|✚ 3…3⚑ 1] 
08:52 $ 

Not working with bugsnag

I can't run properly with tinx, but I am able to run the same command in tinker.

Tinx – something awesome is about to happen.
Psy Shell v0.8.16 (PHP 7.1.11 — cli) by Justin Hileman

u(9);
PHP Fatal error: Call to undefined function u() in eval()'d code on line 1
$user = User::find(9);
[!] Aliasing 'User' to 'App\User' for this Tinker session.
InvalidArgumentException with message 'Invalid API key'

InvalidArgumentException with message 'Invalid API key' this is error message bring by Bugsnag.

php:-
PHP 7.1.11 (cli) (built: Oct 27 2017 11:00:43) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
with Xdebug v2.5.5, Copyright (c) 2002-2017, by Derick Rethans

laravel:-
5.5.28

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.