anahkiasen / janitor
Janitor is a tool to help you remove unused code, views and assets from your codebase.
Requires
- php: >=5.4.0
- illuminate/config: ~4.2
- illuminate/support: ~4.2
- symfony/yaml: ^2.6
- twig/twig: ^1.18
Requires (Dev)
- illuminate/console: ~4.2
- illuminate/filesystem: ~4.2
- illuminate/routing: ~4.2
- mockery/mockery: ^0.9.4
- phpunit/phpunit: ^4.6
- symfony/var-dumper: ^2.6
This package is auto-updated.
Last update: 2024-12-08 01:25:23 UTC
README
Janitor is a tool to help you remove unused code, routes, views and assets from your codebase.
Install
Simply run the following command via Composer:
$ composer require anahkiasen/janitor --dev
Then add Janitor's service provider to your application's local providers:
'Janitor\JanitorServiceProvider',
Usage
Command-line
You can see the various things Janitor can do by simply running:
$ php artisan list janitor
Programmatically
Janitor can also be used programmatically, in order to do so:
<?php // Define your codebase $codebase = new Janitor\Codebase('app'); // Create an instance of any of Janitor's analyzer classes $analyzer = new Janitor\Services\Analyzers\ViewsAnalyzer($codebase); // Tell it which files you wish to analyze, and run the process $analyzer->setFiles('app/views'); $files = $analyzer->analyze();
Here, $files
will be a Collection of instances of AbstractAnalyzedEntity.
Its most important property is the usage
property, it's an integer whose value goes from 0 (file unused) to 1 (file used). The value can vary between these two points to indicate how certain Janitor is that the file is used.
{ "root": "/Users/foobar/Sites/foo/bar/app/views", "name": "_emails/feedback.twig", "usage": 0 }
Available analyzers
Contributions and suggestions are welcome.
Testing
$ phpunit
Contributing
Please see CONTRIBUTING for details.
License
The MIT License (MIT). Please see License AbstractAnalyzedFile for more information.