Fearless refactoring, it does a lot of smart checks to find certain errors.

Overview

Find Bugs Before They Bite

widgetize_header

Built with ❤️ for lazy laravel developers ;)

Why repeat the old errors, if there are so many new errors to commit. (Bertrand Russel)

Give your eyes a rest, we will detect and fix them for you.

Required Laravel Version Required PHP Version Latest Version on Packagist Quality Score Total Downloads Today Downloads

Key things to know:

  • It is created to be smarter than phpstorm and other IDEs in finding errors.
  • It is created to understand laravel run-time and magic.
  • It does not show you stupid false errors, all the errors are really errors.
  • Even If you have written a lot of tests for your app, you may still need this.
  • It can refactor your code, by applying early returns automatically.
  • It is written from scratch to yield the maximum performance possible.

🎞️ Video tutorial here

Your Stars Make Us Do More

If you found this package useful, and you want to encourage the maintainer to work on it, just press the star button to declare your willingness.

Stargazers

⬇️ Installation

You can install the package via composer:

composer require imanghafoori/laravel-microscope --dev

You may also publish config file:

php artisan vendor:publish

💎 Usage

Most Important commands:

You can run:

🔹 php artisan search_replace

🔹 php artisan check:early_returns

🔹 php artisan check:all


Less Important commands:

🔹 php artisan check:views

🔹 php artisan check:routes

🔹 php artisan check:psr4 {-s|--nofix}

🔹 php artisan check:imports {-s|--nofix}

🔹 php artisan check:stringy_classes

🔹 php artisan check:dd

🔹 php artisan check:bad_practices

🔹 php artisan check:compact

🔹 php artisan check:blade_queries

🔹 php artisan check:action_comments

🔹 php artisan check:extract_blades

🔹 php artisan pp:route

🔹 php artisan check:generate

🔹 php artisan check:endif

🔹 php artisan check:events

🔹 php artisan check:gates

Also You will have access to some global helper functions:

  • microscope_dd_listeners($event);

In case you wonder what are the listeners and where are they?! You can use this (0_o) microscope_dd_listeners(MyEvent::class); This call, also can be in boot or register as well. And it works like a normal dd(...); meaning that it will halt.

📖 What the Commands do?

Lets start with:

php artisan search_replace {--name=pattern_name} {--tag=some_tag}

This is a smart and very powerful search/replace functionality which can be a real "time saver" for you.

Defining patterns:

If you run the command artisan search_replace for the first time, it will create a search_replace.php file in the project's root. Then, you can define your patterns, within that file.

Examples:

Lets define a pattern to replace the optional() global helper with the ?-> php 8 null safe operator:

return [
    'optional_to_nullsafe' => [
        'search' => '"<global_func_call:optional>"("<in_between>")->',
        'replace' => '"<2>"?->',
        // 'tag' => 'php8,refactor',
        // 'predicate' => function($matches, $tokens) {...},
        // 'mutator' => function($matches) {...},
        // 'post_replace' => [...],
        // 'avoid_result_in' => [...],
        // 'avoid_syntax_errors' => false,
        // 'filters' => [...],
    ]
];
  • Here the key optional_to_nullsafe is the "unique name" of your pattern. (You can target your pattern by running php artisan search_replace --name=optional_to_nullsafe)
  • The search pattern has "<in_between>" placeholder which captures everything in between the pair of parentesis.
  • In the replace block we substitute what we have captured by the first placeholder by the "<1>". If we have more placeholders, we could have had "<2>" and etc.
  • In the tag block we can mention some tags as an array of strings or a string seperated by commas and target them by --tag flag: php artisan search_replace --tag=php8

Placeholders:

Here is a copmerehensive list of placeholders you can use:

  • "<var>" or "<variable>": for variables like: $user
  • "<str>" or "<string>": for hard coded strings: 'hello' or "hello"
  • "<class_ref>": for class references: \App\User::where(... , User::where
  • "<full_class_ref>": only for full references: \App\User::
  • "<until>": to capture all the code until you reach a certain character.
  • "<comment>": for commands (does not capture doc-blocks)
  • "<doc_block>": for doc-blocks
  • "<statement>": to capture a whole php statement.
  • "<name:nam1,nam2>" or "<name>": for method or function names. ->where or ::where
  • "<white_space>": for whitespace blocks
  • "<bool>" or '<boolean>': for true or false (acts case-insensetive)
  • "<number>": for numeric values
  • "<cast>": for type-casts like: (array) $a;
  • "<int>" or "<integer>": for integer values
  • "<visibility>": for public, protected, private
  • "<float>": for floating point number
  • "<global_func_call:func1,func2>": to detect global function calls.
  • "<in_between>": to capture code within a pair of {...} or (...) or [...]
  • "<any>": captures any token.
  • You can also define your own keywords if needed!

You just define a class for your new keyword and append the class path to the end of Finder::$keywords[] = MyKeyword::class property. Just like the default keywords.

Example:

1 - Lets say you want to find only the "comments" which contain the word "todo:" in them.

 'todo_comments' => [
        'search' => '"<comment>"',
        'predicate' => function($matches) {    //   <====  here we check comment has "todo:"
            $comment = $matches[0]; // first placehoder value
            $content = $comment[1]; // get its content
            
            return Str::containts($content, 'todo:') ? true : false;
        },
]

Note: If you do not mention the 'replace' key it only searches and reports them to you.

2 - Ok, now lets say you want to remove the "todo:" word from your comments:

 'remove_todo_comments' => [
    'search' => '"<comment>"',      //   <=== we capture any comment
    'replace' => '"<1>"',

    'predicate' => function($matches) {
        $comment = $matches[0]; // first matched placehoder
        $content = $comment[1];

        return Str::containts($content, 'todo:') ? true : false;
    },

    'mutator' => function ($matches) {       //  <=== here we remove "todo:"
        $matches[0][1] = str_replace('todo:', '', $matches[0][1]);

        return $matches;
    }
]

Converts: // todo: refactor code Into: // refactor code

Mutator:

In mutators you are free to manipulate the $matched values as much as you need to before replacing them in the results. You can also mention a static method instead of a function, like this: [MyClass::class, 'myStaticMethod']

3 - Lets say you want to put the optional comma for the last elements in the arrays if they are missing.

    'enforce_optional_comma' => [
        'search' => '"<white_space>?"]',
        'replace' => ',"<1>"]',
        'avoid_syntax_errors' => true,
        'avoid_result_in' => [
           ',,]',
           '[,]',
           '"<var>"[,]'
       ],
    ]

In this case our pattern is not very accurate and in some cases it may result in syntax errors. Because of that we turn on php syntax validator to check the end result, but that costs us a performance penalty!!! In order to exclude the usage of php, to validate the end results we have mentioned the avoid_result_in so that if they happen in the end result it skips.

  • Note: The ? in the "<white_space>?" notes this is an optional placeholder.

If you are curious to see a better pattern which does not need any syntax checking, try this:

'enforce_optional_comma' => [
       'search' => '"<1:any>""<2:white_space>?"["<3:until_match>"]',
       'replace' => '"<1>""<2>"["<3>",]',
       'avoid_result_in' => [
           ',,]',
           '[,]'
       ],
       'predicate' => function ($matches) {
           $type = $matches['values'][0][0];

           return $type !== T_VARIABLE && $type !== ']';
       },
       'post_replace' => [
           '"<1:white_space>",]' => ',"<1>"]'
       ]
],

This is more complex but works much faster. (since it does not need the php syntax validator)

  • Here 'post_replace' is a pattern which is applied only and only on the resulting code to refine it, and NOT on the entire file.

  • You can optionally comment your placeholders (as above "<1:any>") with numbers, so that you know which one corresponds to which when replaced.

Filters:

Currently the microscope offers only two built-in filters: is_sub_class_of and in_array

Can you guess what the heck this pattern is doing?!

 'mention_query' => [
      'search' => '"<1:class_ref>"::"<2:name>"'
      'replace' => '"<1>"::query()->"<2>"',
      'filters' => [
          1 => [
              'is_sub_class_of' => \Illuminate\Database\Eloquent\Model::class
          ],
          2 => [
              'in_array' => 'where,count,find,findOrFail,findOrNew'
          ]
      ]
  ]

It converts these:

User::where(...)->get();

\App\Models\User::find(...);

Into these:

User::query()->where(...)->get();

\App\Models\User::query()->find(...);
  • The filters here ensure that the captured class reference is a laravel Model and the mathod name is one of the names mentioned in the list.

So it does not tamper with something like this:

User::all();            // The `all` method can not be preceeded with `query`

UserRepo::where(...);   /// UserRepo is not a model
  • This is something which you can never do by regex.

Capturing php "statements":

Lets say we want to opt-into php 7.4 arrow functions:

'fn' => [
    'search' => 'function ("<in_between>")"<until>"{ "<statement>" }',
    'replace' => 'fn ("<1>") => "<3>"',
    'tags' => 'php74,refactor',
    'mutator' => function ($matches) {
      $matches[2][1] = str_replace(['return ', ';'], '', $matches[2][1]);

      return $matches;
    }
]

In this example, we have mentioned one single "statement" in the body of the function. So if it encounters a function with two or more statements it will ignore that.

$closure = function ($a) use ($b) {
    return $a + $b;
};

// will become:
$closure = fn($a) => $a + $hello;

But this is not captured:

$closure = function ($a) {
    $a++;
    return $a + $b;
};

Difference between "<statement>" and "<until>";

They seem to be very similar but there is an important case which you can not use "<until>"; in order to cover it properly!

$first = $a + $b;

$second = function ($a) {
    $a++;

    return $a;
};

If we define our pattern like this:

return [
    'staty' => [
        'search' => '"<var>" = "<until>";',   
    ]
];

For $c = $a + $b; they act the same way, but for the second one "<until>"; will not capture the whole closure and will stop as soon as it reaches $a++; and that is a problem.

But if you define your pattern as: '"<var>" = "<statement>"' it would be smart enough to capture the correct semi-colon at the end of closure definition and whole close would be captured.

Capturing global function calls:

Lets say you want to eliminate all the dd(...) or dump(...) before pushing to production.

return [
    'remove_dd' => [
        'search' =>  "'<global_func_call:dd,dump>'('<in_between>');", 
        'replace' => ''
    ]
];

This will NOT capture cases like below:

$this->  dd('hello');          // is technically a method call
User::   dd('I am static');    // is technically a static method call
new      dd('I am a classs');  // here "dd" is the name of a class.
   

But will detect and remove real global dd() calls with whatever parameters they have recieved.

dd(                // <=== will be detected, even the pattern above is written all in one line.
   auth('admin')
        ->user()->id   
);
    
    
\dd(1);
dd(1);
dump(1);
    

Repeating patterns:

Lets say we want to refactor:

User:where('name', 'John')->where('family', 'Dou')->where('age', 20)->get();

into:

User:where([
    'name' => 'John',
    'family' => 'Dou',
    'age'=> 20,
])->get();

Ok, how the pattern would look like then?!

"group_wheres" => [
       
       'search' => '<1:class_ref>::where('<2:str>', '<3:str>')'<repeating:wheres>'->get();'
       
       'replace' => '"<1>"::where([
           "<2>" => "<3>",
           "<repeating:1:key_values>"])->get();',

       'named_patterns' => [
           'wheres' => '->where("<str>", "<str>")"<white_space>?"',
           'key_values' => '"<1>" => "<2>","<3>"',
       ]
   ]

Nice yeah??!

Possibilities are endless and the sky is the limit...


php artisan check:early_returns

This will scan all your Psr-4 loaded classes and flattens your functions and loops by applying the early return rule. For example:

<?php

foreach ($products as $product) {
    if ($someCond) {
        // A lot of code 1
        // A lot of code 1
        // A lot of code 1
        // A lot of code 1
        // A lot of code 1
        if ($someOtherCond) {
            // A lot more code 2
            // A lot more code 2
            // A lot more code 2
            // A lot more code 2 
            // A lot more code 2
            //
        } // <--- closes second if
    } // <--- closes first if
}

Will be discovered and converted into:

<?php

foreach ($products as $product) {
    if (! $someCond) {
        continue;
    }
    
    // A lot of code 1
    // A lot of code 1
    // A lot of code 1
    // A lot of code 1
    // A lot of code 1

    if (! $someOtherCond) {
        continue;
    }
 
    // A lot more code 2
    // A lot more code 2
    // A lot more code 2
    // A lot more code 2 
    // A lot more code 2
}

The same thing will apply for functions and methods, but with return

<?php

if ($cond1) {
    if ($cond2) {
        ....       
    }
}

// merge into:

if ($cond1 && $cond2) { 
    ...  
}
  • It also supports the ruby-like if():/endif; syntax;
<?php

if ($var1 > 1):
    if ($var2 > 2):
        echo 'Hey Man';
    endif;
endif;

// or if you avoid putting curly braces...
if ($var1 > 1)
    if ($var2 > 2)
        echo 'Hey Man';

Although this type of refactoring is totally safe and is guaranteed to do the same thing as before, but be careful to commit everything before trying this feature, in case of a weird bug or something.


php artisan check:psr4
  • It checks for all the psr4 autoloads defined in the composer.json file and goes through all the classes to have the right namespace, according to PSR-4 standard.
  • It automatically corrects namespaces (according to PSR-4 rules)
  • It also checks for references to the old namespace with the system and replaces them with the new one.

php artisan check:generate

You make an empty file, we fill it, based on naming conventions.

If you create an empty .php file which ends with ServiceProvider.php after running this command: 1 - It will be filled with a boilerplate and correct Psr-4 namespace. 2 - It will be appended to the providers array in the config/app.php


php artisan check:imports
  • It checks all the imports (use statements) to be valid and reports invalid ones.
  • It auto-corrects some of the references, it no ambiguity is around the class name.
  • It can understand the laravel aliased classes so use Request; would be valid.

php artisan check:bad_practices
  • It detects bad practices like env() calls outside of the config files.

php artisan check:routes
  • It checks that your routes refer to valid controller classes and methods.
  • It checks all the controller methods to have valid type-hints.
  • It scans for route(), redirect()->route(), \Redirect::route() to refer to valid routes.
  • It will report the public methods of controllers, which have no routes pointing to them. In other words dead controllers are detected.

php artisan check:compact
  • In php 7.3 if you "compact" a non-existent variable you will get an error, so this command checks the entire project for wrong compact() calls and reports to you, which parameters should be removed.

php artisan check:blade_queries
  • Blade files should not contain DB queries. we should move them back into controllers and pass variables. This command searches all the blade files for Eloquent models and DB query builder and shows them if any.

php artisan check:extract_blades
  • If you want to extract a blade partial out and make it included like: @include('myPartials.someFile')

you can use {!! extractBlade('myPartials.someFile') !!} in your blade files to indicate start/end line and the path/name of the partial you intend to be made.

 <html>
      
      {!! extractBlade('myPartials.head') !!}
          <head>...</head>
      {!! extractBlade() !!}

      
      {!! extractBlade('myPartials.body') !!}
          <body>...</body>
      {!! extractBlade() !!}
      
 </html>

After you execute php artisan check:extract_blades it will become:

<html>
    @include('myPartials.head')
    @include('myPartials.body')
</html>

Also, it will create:

  • resources/views/myPartials/head.blade.php
  • resources/views/myPartials/body.blade.php

and put the corresponding content in them.

  • It is also compatible with namespaced views in modular laravel applications. So this syntax will work: 'MyMod::myPartials.body'

php artisan check:action_comments
  • This adds annotations in the controller actions so that you know which route is pointing to the current controller action.

php artisan pp:route
  • First you have to put this in your route file: microscope_pretty_print_route('my.route.name');
  • You can also pass the Controller@method syntax to the function.
  • You can call it multiple times in order to pretty-print multiple routes.

php artisan check:views
  • It scans your code and find the view() and View::make() and reports if they refer to the wrong files.
  • It scans your blade files for @include() and @extends() and reports if they refer to the wrong files.

Also, it can detect unused variables which are passed into your view from the controller like this: view('hello', [...]); For that you must open up the page in the browser and then visit the log file to see a message like this:

local.INFO: Laravel Microscope: The view file: welcome.index-1 at App\Http\Controllers\HomeController@index has some unused variables passed to it:   
local.INFO: array ('$var1' , '$var2');

Remember some variables are passed into your view from a view composer and not the controller. Those variables are also taken into consideration when detecting unused variables.


php artisan check:events

For example consider:

Event::listen(MyEvent::class, '\App\Listeners\MyListener@myMethod');

1 - It checks the \App\Listeners\MyListener classpath to be valid.

2 - It checks the myMethod to exist on the MyListener class

3 - It checks the myMethod to have the right type-hint (if any) in its signature, for example:

public function myMethod(OtherEvent $e) // <---- notice type-hint here
{
    //
}

This is a valid but wrong type-hint, and will be reported to you. Very cool, isn't it ??!

  • Note that it does not matter how you are setting your event listener,

1- in the EventServiceProvider,

2- By Event::listen facade,

3- By Subscriber class... or any other way. The error would be found. :)


php artisan check:gates

It checks the validity of all the gates you have defined, making sure that they refer to a valid class and method.

It also checks for the policy definitions to be valid.

Gate::policy(User::class, 'UserPolicy@someMethod');
Gate::define('someAbility', 'UserGate@someMethod');

1 - It checks the User classpath to be valid.

2 - It checks the UserPolicy classpath to be valid.

3 - It checks the someMethod to exist.


and more features will be added soon. ;)

Credits

License

The MIT License (MIT). Please see License File for more information.


🙋 Contributing

If you find an issue or have a better way to do something, feel free to open an issue, or a pull request. If you use laravel-microscope in your open source project, create a pull request to provide its URL as a sample application in the README.md file.

Security

If you discover any security-related issues, please email [email protected] instead of using the issue tracker.

More from the author:

Laravel HeyMan

💎 It allows us to write expressive code to authorize, validate and authenticate.


Laravel Terminator

💎 A minimal yet powerful package to give you the opportunity to refactor your controllers.


Laravel AnyPass

💎 It allows you to login with any password in the local environment only.


Eloquent Relativity

💎 It allows you to decouple your eloquent models to reach a modular structure


Todo:

  • Detect Bad code
  • Facadize static method calls
  • Detect return keyword in eloquent relations
  • Detect wrong action() calls
  • Enhance blocky code detection
  • Detect return abort();
  • Detect un-registered service providers
  • Detect unused middlewares
A man will never fail unless he stops trying.

Albert einstein
Comments
  • file_get_contents(): Read of 8192 bytes failed with errno=21 Is a directory

    file_get_contents(): Read of 8192 bytes failed with errno=21 Is a directory

    Hi, first of all thanks for you awesome work!

    It seems that all namespace-related commands throw this error, namely:

    • php artisan check:views
    • php artisan check:psr4 {-s|--nofix}
    • php artisan check:imports {-s|--nofix}
    • php artisan check:dd
    • php artisan check:bad_practices
    • php artisan check:all

    I guess this happens, as there are additional folders in my app folder. Simply put unexpected directories.

    Cheers

    solved Needs for info 
    opened by Eixix 28
  • php artisan check:action_comments

    php artisan check:action_comments

    Hi Brother, I am having the below error while running action_comments command.

    Commentify Route Actions... PHP Fatal error: Cannot redeclare active_menu() (previously declared in C:\xampp\htdocs\laravel\app\Helpers\helpers.php:10) in C:\xampp\htdocs\laravel\app\Helpers\helpers.php on line 13

    Symfony\Component\Debug\Exception\FatalErrorException : Cannot redeclare active_menu() (previously declared in C:\xampp\htdocs\laravel\app\Helpers\helpers.php:10)

    at C:\xampp\htdocs\laravel\app\Helpers\helpers.php:13 9| 10| function active_menu($url) 11| { 12| return $url == request()->path() ? 'active' : '';

    13| } 14| 15| function active_menu_frontend($url) 16| { 17| return $url == request()->path() ? 'current-menu-item' : '';

    Whoops\Exception\ErrorException : Cannot redeclare active_menu() (previously declared in C:\xampp\htdocs\laravel\app\Helpers\helpers.php:10)

    at C:\xampp\htdocs\laravel\app\Helpers\helpers.php:13 9| 10| function active_menu($url) 11| { 12| return $url == request()->path() ? 'active' : '';

    13| } 14| 15| function active_menu_frontend($url) 16| { 17| return $url == request()->path() ? 'current-menu-item' : '';

    Exception trace:

    1 Whoops\Run::handleError("Cannot redeclare active_menu() (previously declared in C:\xampp\htdocs\laravel\app\Helpers\helpers.php:10)", "C:\xampp\htdocs\laravel\app\Helpers\helpers.php") C:\xampp\htdocs\laravel\vendor\filp\whoops\src\Whoops\Run.php:408

    2 Whoops\Run::handleShutdown() [internal]:0

    opened by abbasmashaddy72 20
  • Error in

    Error in "php artisan check:import"

    Hello Mr. Iman When I run "php artisan check:import", This error occorred in end of returned messages:

     ErrorException  : Class 'Illuminate\Support\Facades\Input' not found
    
      at C:\wamp64\www\xxx\vendor\laravel\framework\src\Illuminate\Foundation\AliasLoader.php:80
        76|             return true;
        77|         }
        78|
        79|         if (isset($this->aliases[$alias])) {
      > 80|             return class_alias($this->aliases[$alias], $alias);
        81|         }
        82|     }
        83|
        84|     /**
    
      Exception trace:
    
      1   class_alias("Illuminate\Support\Facades\Input", "Input")
          C:\wamp64\www\xxx\vendor\laravel\framework\src\Illuminate\Foundation\AliasLoader.php:80
    
      2   Illuminate\Foundation\AliasLoader::load("Input")
          [internal]:0
    
      Please use the argument -v to see more details.
    

    I run "composer dump-autoload" command for sometimes too, But as a result, it had no effect! My laravel version is 6.18

    opened by hmoradian 12
  • Doesn't work with Laravel 5.4.36 (which is no problem)

    Doesn't work with Laravel 5.4.36 (which is no problem)

    ..but you might want to specify a minimum of 5.5 in your composer.json

    After putting \Imanghafoori\LaravelMicroscope\LaravelMicroscopeServiceProvider::class, in config/app.php , this results in:

    $ php artisan check
    
    In SpyRouteCollection.php line 14:
                                                                      
      Call to undefined method Illuminate\Routing\Route::getDomain()  
    

    5.4, no getDomain(): https://github.com/laravel/framework/blob/5.4/src/Illuminate/Routing/Route.php 5.5, getDomain(): https://github.com/laravel/framework/blob/5.5/src/Illuminate/Routing/Route.php#L568

    opened by HenkPoley 11
  • Undefined variable $body at vendor/imanghafoori/laravel-microscope/src/Analyzers/ClassMethods.php:59

    Undefined variable $body at vendor/imanghafoori/laravel-microscope/src/Analyzers/ClassMethods.php:59

    I get the following output when running sail artisan check:all:

    (...)

    Checking for route-less controllers...
    
       ErrorException 
    
      Undefined variable $body
    
      at vendor/imanghafoori/laravel-microscope/src/Analyzers/ClassMethods.php:59
         55▕             $methods[] = [
         56▕                 'name' => $name,
         57▕                 'visibility' => $visibility,
         58▕                 'signature' => $signature,
      ➜  59▕                 'body' => Refactor::toString($body),
         60▕                 'startBodyIndex' => [$charIndex, $i],
         61▕                 'returnType' => $returnType,
         62▕                 'nullable_return_type' => $hasNullableReturnType,
         63▕                 'is_static' => $isStatic,
    
          +30 vendor frames 
      31  artisan:37
          Illuminate\Foundation\Console\Kernel::handle()
    

    Do you have any idea where this comes from? I am out of ideas.

    I can share additional code of my project when necessary to debug this issue.

    Thanks a lot !

    feature request php8 solved 
    opened by thyseus 9
  • Problem with correcting namespace

    Problem with correcting namespace

    Hello Iman, I moved some models to a new location and corrected manually their namespaces. And then tried this check:all.

    It converted: use App\Models\Post; to: use /ModuleBlog/Models/Post;

    also in relationships it converted this: return $this->hasOne(\App\Models\Post::class); to return $this->hasOne ( \ /ModuleBlog/Models/Post::class);

    and then in check:psr4 got this error: Symfony\Component\Debug\Exception\FatalThrowableError : syntax error, unexpected '/', expecting identifier (T_STRING) or function (T_FUNCTION) or const (T_CONST) or \ (T_NS_SEPARATOR)

    I would be so thankful if you let me know the reason or kindly fix the bug if there is. Best Regards, Hamed

    solved Linux 
    opened by HPWebdeveloper 9
  • stringy_classes Error

    stringy_classes Error

    Hi! Thank you for this amazing component!

    I have an error when I run the php artisan check:stringy_classes command: It throws the following error output:

    Checking strings...
    PHP Fatal error:  Cannot declare class App\Task, because the name is already in use in /home/luckas/Code/mol/interno/app/Task.php on line 9
    
       Symfony\Component\ErrorHandler\Error\FatalError 
    
      Cannot declare class App\Task, because the name is already in use
    
      at app/Task.php:9
         5| use Illuminate\Database\Eloquent\Model;
         6| use Illuminate\Database\Eloquent\SoftDeletes;
         7| use Illuminate\Support\Carbon;
         8| 
      >  9| class Task extends Model
        10| {
        11|     use SoftDeletes;
        12| 
        13|     protected $dates = [
    
    
       Whoops\Exception\ErrorException 
    
      Cannot declare class App\Task, because the name is already in use
    
      at app/Task.php:9
         5| use Illuminate\Database\Eloquent\Model;
         6| use Illuminate\Database\Eloquent\SoftDeletes;
         7| use Illuminate\Support\Carbon;
         8| 
      >  9| class Task extends Model
        10| {
        11|     use SoftDeletes;
        12| 
        13|     protected $dates = [
    
          +1 vendor frames 
      2   [internal]:0
          Whoops\Run::handleShutdown()
    

    I have only one App\Task class model, Is this a false positive or is it another error?

    opened by lsfiege 9
  • Laravel Telescope default config file throws error

    Laravel Telescope default config file throws error

    My stack as follows:-

    PHP 7.3 Laravel Framework 7.10.2 laravel-microscope v1.0.34

    Errors reported by Laravel Microscope:-

    Class does not exist:
    Laravel\Telescope\Watchers   <==== does not exist
    at config\telescope.php:113
    

    16 errors all together comes from telescope.php

    Thx.

    opened by rognales 9
  • Class does not exist due to alias import

    Class does not exist due to alias import

    My stack as follows:-

    PHP 7.4 Laravel Framework 6.18.10 laravel-microscope 1.0

    Errors reported by Laravel Microscope:-

    Class does not exist: App\Traits\...   <==== does not exist
    at app\Traits\HasRolesTrait.php:19
    

    Here's the traits

    namespace App\Traits;
    
    /**
     * @mixin \App\Models\BaseModel
     */
    trait HasRolesTrait
    

    And the import statement from app\User.php

    use App\Traits\HasRolesTrait as HasRoles;
    
    opened by rognales 9
  • Class not detected if declared in same file

    Class not detected if declared in same file

    When launching php artisan check:imports on the following code:

    <?php
    namespace Toto;
    
    class Super {
    }
    
    class Amazing {
      private Super $super;
    
      public function __construct() {
        $this->super = new Super();
      }
    }
    

    the following error is displayed: Class does not exist: Toto\Super at Toto/Amazing.php:11

    whereas I expect that the class Super should be detected.

    irrelevant 
    opened by melicerte 8
  • Fails To Install

    Fails To Install

    Using version ^1.0 for imanghafoori/laravel-microscope
    ./composer.json has been updated
    Running composer update imanghafoori/laravel-microscope
    Loading composer repositories with package information
    Updating dependencies
    Lock file operations: 1 install, 0 updates, 0 removals
      - Locking imanghafoori/laravel-microscope (v1.0.180)
    Writing lock file
    Installing dependencies from lock file (including require-dev)
    Package operations: 1 install, 0 updates, 0 removals
      - Downloading imanghafoori/laravel-microscope (v1.0.180)
      - Installing imanghafoori/laravel-microscope (v1.0.180): Extracting archive
    Generating optimized autoload files
    > Illuminate\Foundation\ComposerScripts::postAutoloadDump
    > @php artisan package:discover --ansi
    
       TypeError 
    
      is_dir(): Argument #1 ($filename) must be of type string, array given
    
      at vendor/imanghafoori/laravel-microscope/src/SpyClasses/SpyRouter.php:56
         52▕             $err = "['middlewares' => ...] key passed to Route::group(...) is not correct.";
         53▕             $this->routeError($info, $err, "Incorrect 'middlewares' key.");
         54▕         }
         55▕ 
      ➜  56▕         if ($ns && isset($attributes['namespace']) && ! is_dir($dir) && \str_replace(['\\', '/'], DIRECTORY_SEPARATOR, $ns) !== $dir) {
         57▕             $err = "['namespace' => "."'".$attributes['namespace'].'\'] passed to Route::group(...) is not correct.';
         58▕             $this->routeError($info, $err, 'Incorrect namespace.');
         59▕         }
         60▕     }
    
          +30 vendor frames 
      31  [internal]:0
          Illuminate\Foundation\Application::Illuminate\Foundation\{closure}()
    
          +5 vendor frames 
      37  artisan:37
          Illuminate\Foundation\Console\Kernel::handle()
    Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1
    
    Installation failed, reverting ./composer.json and ./composer.lock to their original content.
    
    enhancement solved 
    opened by HDVinnie 8
  • Support Facade fixes like \Auth, \Log

    Support Facade fixes like \Auth, \Log

    Hi There,

    Been using your package happily for the past years. Thanks alot!

    I wonder if you can support removing \Auth and replacing with proper imports

    feature request 
    opened by rognales 1
  • Conflict with ResponseReceived, the http client event

    Conflict with ResponseReceived, the http client event

    When I install the package the ResponseReceived listeners won't work from cli. Like if I make an HTTP request from tinker, the listeners of ResponseReceived won't call. https://laravel.com/docs/8.x/http-client#events

    minor 
    opened by Daniyal-Javani 1
Releases(v1.0.272)
Owner
Iman
Coding is sport, it is art, it is science.
Iman
🥳🔐 This package is a Laravel package that checks if an email address is a spammer

This package is a Laravel package that checks if an email address is a spammer. It verifies your signups and form submissions to confirm that they are legitimate.

Endurance, the Martian 15 Dec 19, 2022
Send PHP errors to Flare

Send PHP errors to Flare This repository contains a PHP client to send PHP errors to Flare. Documentation You can find the documentation of this packa

Spatie 64 Dec 26, 2022
Laravel 4.* and 5.* service providers to handle PHP errors, dump variables, execute PHP code remotely in Google Chrome

Laravel 4.* service provider for PHP Console See https://github.com/barbushin/php-console-laravel/releases/tag/1.2.1 Use "php-console/laravel-service-

Sergey 73 Jun 1, 2022
💡 Full-featured code intelligence and smart autocomplete for Sublime Text

SublimeCodeIntel This Code Intelligence plugin for Sublime Text provides an interface to CodeIntel. CodeIntel is a code intelligence engine that was p

null 5.1k Dec 27, 2022
Laravel package to find performance bottlenecks in your laravel application.

Laravel Meter Laravel Meter monitors application performance for different things such as requests, commands, queries, events, etc and presents result

Sarfraz Ahmed 230 Dec 27, 2022
Laravel Abdal Detector - Find info about IP , OS and web browser from your client

Laravel Abdal Detector - Find info about IP , OS and web browser from your client

 Abdal Security Group 1 Mar 24, 2022
You already have your dream house? Sam Building will help you find the perfect home.

SAM BUILDING Setup Fork or clone this repo! git clone github.com/Igorballo/Real-Estate-App.git Installation des dépendances npm install #or yarn insta

null 4 Nov 29, 2022
Job Portal - Find your dream job here Various career opportunities await you

Find your dream job here Various career opportunities await you. Find the right career and connect with companies anytime, anywhere ?? free access to search for jobs, post resumes, and research companies. ??

Ossama Mehmood 샘 5 Nov 14, 2022
This Plugin runs commands when a player does a certain emote

The EmoteCommands Plugin This Plugin runs commands when a player does a certain emote You will need a pocketmine server of at least version 4.0.0 Usag

DiamondStrider1 1 Jan 24, 2022
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
This package implements 0-1 Knapsack Problem algorithm i.e. allows to find the best way to fill a knapsack of a specified volume with items of a certain volume and value.

This package implements "0-1 Knapsack Problem" algorithm i.e. allows to find the best way to fill a knapsack of a specified volume with items of a certain volume and value.

Alexander Makarov 9 Sep 8, 2022
Platform for Citizen Engagement, Smart Communities, Smart Cities in the context of the Sustainable Development Goals 🏙️👩‍💻👨‍💼🙋‍♀️🙋‍♂️🦾🤖

Civikmind Plataforma Libre y de código abierto para la Participación Ciudadana, Veeduría Ciudadana, Gestión de Comunidades Inteligentes, Ciudades Inte

Smart Cities Community 29 Dec 8, 2022
The Smart-ID PHP client can be used for easy integration of the Smart-ID solution to information systems or e-services

Smart-ID PHP client Introduction The Smart-ID PHP client can be used for easy integration of the Smart-ID solution to information systems or e-service

SK ID Solutions 16 Oct 23, 2022
Official repository for Find A PR. Find A PR is a platform that curates a list of issues around Laravel based project.

About Find A PR This is the official repository for Find A PR. Find A PR is a platform that curates a list of issues around Laravel based project. Req

Ash Allen 33 Dec 15, 2022
Notifying your users doesn't have to be a lot of work.

Messenger for Laravel Goal To provide a drop-in, application-wide alerting functionality to display various types of alerts and notifications to the u

GeneaLabs, LLC 138 Jul 22, 2022
A lot of scripts and packages in modern PHP demand one or more configuration classes

A lot of scripts and packages in modern PHP demand one or more configuration classes. Mostly, those are a set of properties that can be set, changed or retrieved. However, some of the configurations have a peculiar behaviour - such as boolean properties.

Carlos Artur Curvelo da Silva Matos 2 Mar 8, 2022
Notifying your users doesn't have to be a lot of work.

Messenger for Laravel Goal To provide a drop-in, application-wide alerting functionality to display various types of alerts and notifications to the u

GeneaLabs, LLC 138 Jul 22, 2022
A Simple MVC PHP Framework, integrated with lot of features such as Session, Cookies, Migrations, Database, Factories, Seeding, Bootstrap and Tailwind CSS

Navite A Simple MVC PHP Framework, integrated with lot of features such as Session, Cookies, Migrations, Database, Factories, Seeding, Bootstrap and T

Celionatti 2 Aug 22, 2022
A trait to make building your own custom Laravel Model Searches a lot easier.

BrekiTomasson\LaravelModelFinder A simple trait that makes building your own custom Laravel Model Searches a lot easier and safer. It ensures that you

Breki Tomasson 3 Nov 27, 2022
A command line refactoring tool for PHP

PHP Refactoring Browser Note: This software is under development and in alpha state. Refactorings do not contain all necessary pre-conditions and migh

QafooLabs 562 Dec 30, 2022