GithubHelp home page GithubHelp logo

mehdi-fathi / laravel-microscope Goto Github PK

View Code? Open in Web Editor NEW

This project forked from imanghafoori1/laravel-microscope

0.0 1.0 0.0 137 KB

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

License: MIT License

PHP 100.00%

laravel-microscope's Introduction

Inspects your laravel application code to find errors

Give your eyes a rest, this will check it for you.

This package is created understand laravel magic and be smarter than IDEs or other static analyzers.

widgetize_header

Latest Version on Packagist Build Status Quality Score Total Downloads

Built with โค๏ธ for lazy laravel developers ;)

This package provides a way to find errors without writing any tests.

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.

Installation

You can install the package via composer:

composer require imanghafoori/laravel-microscope --dev

Usage

You can run:

  • php artisan check:event
  • php artisan check:gate
  • php artisan check:view
  • php artisan check:route (checks controller class and method also the blade files path to be correct)
  • php artisan check:psr4 (Auto-corrects namespaces)
  • php artisan check:import (checks all the imports at the top and even non-imported inline class usages within .blade.php files, classes to be valid !)
  • php artisan check:all

What the Commands do?

Lets start with:

php artisan check:event

For example consider:

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

1 - It checks the MyEvent class path to be valid.

2 - It checks the MyListener class path to be valid.

3 - It checks the myMethod to exist.

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

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

This is a 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:gate

It check 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 class path to be valid.

2 - It checks the UserPolicy class path to be valid.

3 - It checks the someMethod to exist.

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)
php artisan check:import
  • It check all the imports (use statements) to be valid.
  • It can understand the laravel aliased classes so use Request; would be valid.
php artisan check:route
  • It check that your routes refer to valid controller classes and methods.
  • It checks the all the controller methods to have valid type-hints.
  • It scans your controller code and find the view() and View::make() and reports if they refer to wrong files.
  • It scans your blade files for @include() and @extends() and reports if they refer to wrong files.

and more features will be added soon. ;)

Security

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

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 it's 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.

โญ Your Stars Make Us Do More โญ

As always if you found this package useful and you want to encourage us to maintain and work on it. Just press the star button to declare your willing.

Stargazers: https://github.com/imanghafoori1/microscope/stargazers

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 login with any password in the local environment only.


Eloquent Relativity

๐Ÿ’Ž It allows you to decouple your eloquent models to reach a modular structure


๐ŸŒ Reward me a banana ๐ŸŒ

Send me as much as a banana costs in your region:

  • DogeCoin: DJEZr6GJ4Vx37LGF3zSng711AFZzmJTouN
  • LiteCoin: ltc1q82gnjkend684c5hvprg95fnja0ktjdfrhcu4c4
  • BitCoin: bc1q53dys3jkv0h4vhl88yqhqzyujvk35x8wad7uf9
  • Ripple: rJwrb2v1TR6rAHRWwcYvNZxjDN2bYpYXhZ
  • Etherium: 0xa4898246820bbC8f677A97C2B73e6DBB9510151e

A man will never fail, unless he stops trying.

Albert einstein

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.