bobanum/revamp

Description of your extension

0.1.7 2023-06-06 19:27 UTC

This package is auto-updated.

Last update: 2024-10-06 22:35:23 UTC


README

A better way to find your files in Laravel!

Total Downloads Latest Stable Version License

| Installation | Usage | Configuration | The Sources | Custom Sources | Diagrams |

Introduction

Revamp takes your normal files hierarchy and adds a _concepts folder filled with links to the important files sorted and grouped by model. Every change made to thoses files will affect the target file since they are the same file.

For example, the model /app/Models.School.php is the same file as _concepts/School/Model.php. Easier to find, easier to maintain.

See the diagrams for more details.

Installation

composer require --dev bobabum/revamp

Usage

Revamp

php artisan revamp

Will add new links but will not delete obsolete links.

Revamp back to delete the concepts folder

php artisan revamp:back

Revamp refresh to delete the concepts folder and recreate it

php artisan revamp:refresh

Configuration

Publish the config file

php artisan vendor:publish --tag=config

Will publish the config file config/revamp.php

The configs

The Sources

Custom sources

You can add custom sources to the config file. The key is the destination file or folder.

  • If the key starts with /, the value must then be another array of custom sources and the key will be the destination folder.
  • The key (destination) can be a preg_replace replace pattern($1, $2...). The value (source) must then contain a matching number of *. Ex.: '$2/$1.php' => 'views/*/*.php'
  • The value (source) can be a string or an array.
  • If it's an array:
    1. the first value will be the source file or glob pattern
    2. the second value will be a callable that returns a path like resource_path or base_path
    3. the third value will be a callable that will let revamp modify the matches for every * in the source file or glob pattern. Ex.: fn(&$matches) => $matches[1] = strtoupper($matches[1])

Diagrams

<style> .columns { display: grid; grid-template-columns: 1fr max-content; justify-content: space-between; gap: .5em; } .columns>div { line-height: 1em; overflow-x: hidden; font-size: 0.8em; } .columns pre { } .columns code { line-height: 1.1em; letter-spacing: -0.1ch; white-space: no-wrap !important; } } </style>

Original Laravel Hierarchy

📦my-laravel-project
 ┣━📂app
 ┃ ┣━📂Http
 ┃ ┃ ┣━📂Controllers
 ┃ ┃ ┃ ┣━📜Controller.php
 ┃ ┃ ┃ ┣━📜DepartmentController.php
 ┃ ┃ ┃ ┣━📜SchoolController.php
 ┃ ┃ ┃ ┗━📜TeacherController.php
 ┃ ┃ ┗━📂Requests
 ┃ ┃   ┣━📜StoreDepartmentRequest.php
 ┃ ┃   ┣━📜StoreSchoolRequest.php
 ┃ ┃   ┣━📜StoreTeacherRequest.php
 ┃ ┃   ┣━📜UpdateDepartmentRequest.php
 ┃ ┃   ┣━📜UpdateSchoolRequest.php
 ┃ ┃   ┗━📜UpdateTeacherRequest.php
 ┃ ┣━📂Models
 ┃ ┃ ┣━📜Department.php
 ┃ ┃ ┣━📜School.php
 ┃ ┃ ┣━📜Teacher.php
 ┃ ┃ ┗━📜User.php
 ┃ ┗━📂Policies
 ┃   ┣━📜DepartmentPolicy.phpz
 ┃   ┣━📜SchoolPolicy.php
 ┃   ┗━📜TeacherPolicy.php
 ┣━📂concepts
 ┃ ┣━📂Department
 ┃ ┃ ┣━📜Controller.php
 ┃ ┃ ┣━📜Factory.php
 ┃ ┃ ┣━📜migration.php
 ┃ ┃ ┣━📜Model.php
 ┃ ┃ ┣━📜Seeder.php
 ┃ ┃ ┣━📜StoreRequest.php
 ┃ ┃ ┗━📜UpdateRequest.php
 ┃ ┣━📂School
 ┃ ┃ ┣━📂views
 ┃ ┃ ┃ ┗━📜index.blade.php
 ┃ ┃ ┣━📜Controller.php
 ┃ ┃ ┣━📜Factory.php
 ┃ ┃ ┣━📜migration.php
 ┃ ┃ ┣━📜Model.php
 ┃ ┃ ┣━📜Policy.php
 ┃ ┃ ┣━📜Seeder.php
 ┃ ┃ ┣━📜StoreRequest.php
 ┃ ┃ ┗━📜UpdateRequest.php
 ┃ ┣━📂Teacher
 ┃ ┃ ┣━📜Controller.php
 ┃ ┃ ┣━📜Factory.php
 ┃ ┃ ┣━📜migration.php
 ┃ ┃ ┣━📜Model.php
 ┃ ┃ ┣━📜Policy.php
 ┃ ┃ ┣━📜Seeder.php
 ┃ ┃ ┣━📜StoreRequest.php
 ┃ ┃ ┗━📜UpdateRequest.php
 ┃ ┗━📂User
 ┃   ┣━📜Factory.php
 ┃   ┣━📜migration.php
 ┃   ┗━📜Model.php
 ┣━📂database
 ┃ ┣━📂factories
 ┃ ┃ ┣━📜DepartmentFactory.php
 ┃ ┃ ┣━📜SchoolFactory.php
 ┃ ┃ ┣━📜TeacherFactory.php
 ┃ ┃ ┗━📜UserFactory.php
 ┃ ┣━📂migrations
 ┃ ┃ ┣━📜create_users_table.php
 ┃ ┃ ┣━📜create_schools_table.php
 ┃ ┃ ┣━📜create_departments_table.php
 ┃ ┃ ┗━📜create_teachers_table.php
 ┃ ┗━📂seeders
 ┃   ┣━📜DatabaseSeeder.php
 ┃   ┣━📜DepartmentSeeder.php
 ┃   ┣━📜SchoolSeeder.php
 ┃   ┗━📜TeacherSeeder.php
 ┣━📂resources
 ┃ ┗━📂views
 ┃   ┗━📂school
 ┃     ┣━📜index.blade.php
 ┃     ┗━📜show.blade.php
 ┗━📂routes
   ┣━📜api.php
   ┣━📜channels.php
   ┣━📜console.php
   ┗━📜web.php

Revamped hierarchy in `_concepts` folder:

📦my-laravel-project
 ┣━📂_concepts
 ┃ ┣━📂Department
 ┃ ┃ ┣━📜Controller.php
 ┃ ┃ ┣━📜Factory.php
 ┃ ┃ ┣━📜migration.php
 ┃ ┃ ┣━📜Model.php
 ┃ ┃ ┣━📜Seeder.php
 ┃ ┃ ┣━📜StoreRequest.php
 ┃ ┃ ┗━📜UpdateRequest.php
 ┃ ┣━📂School
 ┃ ┃ ┣━📂views
 ┃ ┃ ┃ ┣━📜index.blade.php
 ┃ ┃ ┃ ┗━📜show.blade.php
 ┃ ┃ ┣━📜Controller.php
 ┃ ┃ ┣━📜Factory.php
 ┃ ┃ ┣━📜migration.php
 ┃ ┃ ┣━📜Model.php
 ┃ ┃ ┣━📜Policy.php
 ┃ ┃ ┣━📜Seeder.php
 ┃ ┃ ┣━📜StoreRequest.php
 ┃ ┃ ┗━📜UpdateRequest.php
 ┃ ┣━📂Teacher
 ┃ ┃ ┣━📜Controller.php
 ┃ ┃ ┣━📜Factory.php
 ┃ ┃ ┣━📜migration.php
 ┃ ┃ ┣━📜Model.php
 ┃ ┃ ┣━📜Policy.php
 ┃ ┃ ┣━📜Seeder.php
 ┃ ┃ ┣━📜StoreRequest.php
 ┃ ┃ ┗━📜UpdateRequest.php
 ┃ ┗━📂User
 ┃   ┣━📜Factory.php
 ┃   ┣━📜migration.php
 ┃   ┗━📜Model.php
 ┗━...