Skip to content
/ revamp Public

Laravel utility to regroup and reorganize your routes, controllers, models, views... into concepts

License

Notifications You must be signed in to change notification settings

bobanum/revamp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Revamp Signature

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

Config Description Default
folder_name The folder where the concepts are stored _concepts
shorten_names If true, will remove the concept's name from the file name. Making Table/Controller.php instead to Table/TableController.php true
sources 🔜The sources of files for one concept (see below). If sources is given, only those sources will be rendered. null for all the sources
excluded_sources 🔜The sources of files to exclude for one concept. If excluded_sources is set, sources will be ignored. null for no excluded sources
excluded_concepts 🔜The concepts to exclude. Ex.: ['App'] null for no excluded concepts
custom_sources The custom sources to add to the sources. (see below) null for no custom sources
custom_sources

The Sources

Source Description Location
Global Some files not linked to a concept Various
Model The model file. 🔍Revamp will use found Models to use as concepts app/Models
Controller The controller file. 🔍Revamp will use found Controllers to use as concepts app/Http/Controllers
Migration The migration file. Revamp will use the migration file creating the table: *_create_*_table.php database/migrations
Seeder The seeder file database/seeders
Factory The factory file database/factories
Policy The policy file app/Policies
Request The requests files (Store and Update) app/Http/Requests
View 🚧 The view folder (not working actually) resources/views
Route The route file (if one create a concept.php in the routes folder) routes
VueModel The vuejs file (if one create a Concept.js in the resources/js/models folder) resources/js
VuePages 🔜 The vuejs pages folder resources/js/pages
VueComponents 🔜 The vuejs components folder resources/js/components

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
 ┗━...

About

Laravel utility to regroup and reorganize your routes, controllers, models, views... into concepts

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages