anahkiasen/janitor

Janitor is a tool to help you remove unused code, views and assets from your codebase.
85 21
Install
composer require anahkiasen/janitor
PHP:>=5.4.0
License:MIT
Last Updated:May 21, 2015
Links: GitHub  ·  Packagist
Maintainer: Anahkiasen

Janitor

Build Status Latest Stable Version Total Downloads Scrutinizer Quality Score Code Coverage Dependency Status Support via Gittip

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

Name Description Status
ViewsAnalyzer Analyzes your codebase and check for unused views
DatabaseAnalyzer Checks your database for dead entries Planned
CodebaseAnalyzer Checks your codebase for unused classes, models, etc Planned
RoutesAnalyzer Checks your views and controllers for unused routes Planned

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.

Related Packages

bnzo/livewire-tmp-cleanup

Schedule-driven cleanup of Livewire temporary uploads on S3-compatible storage (...

421 0
goszowski/laravel-vendor-minify

A vendor minify package, to remove tests and documentation and minifing all php...

3,624 80
edofre/laravel-softdelete-cleanup

Console command to cleanup your database from softdeleted models

26 3
php-tmdb/laravel

Laravel Package for TMDB ( The Movie Database ) API. Provides easy access to the...

53,303 162
kavenegar/laravel

laravel 4 and 5 kavenegar integration

350,771 85