Builder
Prepare your Laravel apps incredibly fast, with various commands, services, facades and boilerplates.
Install / Use
/learn @GrafiteInc/BuilderREADME
Grafite Builder
Grafite has archived this project and no longer supports or develops the code. We recommend using only as a source of ideas for your own code.
Builder - A handful of tools for Rapid Laravel Development
This is a set of tools to help speed up development of Laravel apps. You can start an app with various parts prewritten (Users, User Meta, Roles, Teams). And it comes with a powerful FormMaker which can generate form content from tables, and objects. It can generate epic CRUD prototypes rapidly with full testing scripts prepared for you, requiring very little editing. It also provides an elegant Cryptography tool which is URL friendly. Finally it brings along some friends with LaravelCollective as a vendor.
Author(s):
- Matt Lantz (@mattylantz, mattlantz at gmail dot com)
General Requirements
- PHP 7.1.3+
- OpenSSL
Compatibility and Support
| Laravel Version | Package Tag | Supported | |-----------------|-------------|-----------| | 5.7.x | 2.5.x | no | | 5.6.x | 2.4.x | no | | 5.5.x | 2.3.x | no | | 5.4.x | 2.2.x | no | | 5.3.x | 2.0.x - 2.1.x | no | | 5.1.x - 5.2.x | 1.9.x | no |
Installation
Start a new Laravel project:
laravel new {project_name}
or
composer create-project laravel/laravel {project_name}
Then run the following to add the Grafite Builder
composer require "grafite/builder"
Time to publish those assets! Grafite Builder uses CrudMaker and FormMaker which have publishable assets.
php artisan vendor:publish
or
php artisan vendor:publish --provider="Yab\CrudMaker\CrudMakerProvider"
php artisan vendor:publish --provider="Yab\FormMaker\FormMakerProvider"
You now have Grafite Builder installed. Try out the Starter Kit.
Application Starter Kit
!!! warning "Make sure you followed the getting started instructions!"
Grafite Builder provides an elegant solution for starting an application by building the most basic views, controllers, models and migrations for your application. No need to use the php artisan make:auth because now you can easily start your whole application with this single command:
php artisan grafite:starter
!!! tip "BUT, before we do that lets get a few things set up."
In order to make use of the <u>starter kit</u> you will need to modify some files. Check out the modifications below:
Add the following to your app/Http/Kernel.php in the $routeMiddleware array.
'admin' => \App\Http\Middleware\Admin::class,
'permissions' => \App\Http\Middleware\Permissions::class,
'roles' => \App\Http\Middleware\Roles::class,
'active' => \App\Http\Middleware\Active::class,
If you don't want to worry about email activation then remove this from the route's middleware array:
'active'
Update the App\User::class in: 'config/auth.php' and 'database/factories/UserFactory.php' to this:
App\Models\User::class
Add the following to 'app/Providers/AuthServiceProvider.php' in the boot method
Gate::define('admin', function ($user) {
return ($user->roles->first()->name === 'admin');
});
Gate::define('team-member', function ($user, $team) {
return ($user->teams->find($team->id));
});
Add the following to 'app/Providers/EventServiceProvider.php' in the $listen property
'App\Events\UserRegisteredEmail' => [
'App\Listeners\UserRegisteredEmailListener',
],
You will want to create an sqlite memory test database in the config/database.php
'testing' => [
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => '',
],
Add the following line to the 'phpunit.xml' file
<env name="DB_CONNECTION" value="testing"/>
<env name="MAIL_DRIVER" value="log"/>
Regarding Email Activation
The Starter kit has an email activation component added to the app to ensure your users have validated their email address.
You can disable it by removing the active middleware from the web routes. You will also have to disable the Notification but it
won't cause any problems if you remove the email activation.
For Laravel 5.2 and later
You will also need to set the location of the email for password reminders. (config/auth.php - at the bottom)
'passwords' => [
'users' => [
'provider' => 'users',
'email' => 'emails.password',
'table' => 'password_resets',
'expire' => 60,
],
],
Things to note
You may try and start quickly by testing the registration but please make sure your app's <u>email</u> is configured or it will throw an exception.
You can do this in the .env file easily by setting it to 'log' temporarily
MAIL_DRIVER=log
Last Steps
Once you've added in all these parts you will want to run the starter command!
php artisan grafite:starter
Then you'll have to refresh the list of all classes that need to be included in the project.
composer dump-autoload
Then you'll need to migrate to add in the users, user meta, roles and teams tables. The seeding is run to set the initial roles for your application.
php artisan migrate --seed
Once you get the starter kit running you can register and login to your app. You can then you can visit the settings section of the app and set your role to admin to take full control of the app.
What Starter Publishes
Controllers
Grafite Builder updated the basic controllers to handle things like creating a profile when a user is registered, as well as setting default return routes to dashboard etc. It also provides contollers for handling profile modifications and pages, team management etc. The admin controller handles the admin of users, modifying a user provided the user has the admin role.
- app/Http/Controllers/
- Admin/
- DashboardController.php
- UserController.php
- RoleController.php
- Auth/
- ActivateController.php
- ForgotPasswordController.php
- LoginController.php
- RegisterController.php
- ResetPasswordController.php
- User/
- PasswordController.php
- SettingsController.php
- PagesController.php
- TeamController.php
- Admin/
Middleware
Grafite Builder overwrites the default middleware due to changes in the redirects. It also provides the Admin middleware for route level protection relative to roles.
- app/Http/Middleware/
- Active.php
- Admin.php
- Permissions.php
- RedirectIfAuthenticated.php
- Roles.php
Requests
There are requests provided for handling the creation of Teams and updating of all components. Here we integrate the rules required that are able to run the validations and return errors. (If you're using Grafite Builder FormMaker Facade then it will even handling accepting the errors and highlighting the appropriate fields.)
- app/Http/Requests/
- PasswordUpdateRequest.php
- RoleCreateRequest.php
- TeamCreateRequest.php
- TeamUpdateRequest.php
- UserInviteRequest.php
- UserUpdateRequest.php
Routes
Given that there are numerous routes added to handle teams, profiles, password etc all routes are overwritten with the starter kit.
- routes/web.php
Config
The permissions config file is published, this is a way for you to set access levels and types of permissions Roles can have
- config/permissions.php
Events
The events for various actions.
- app/Events/
- UserRegisteredEmail.php
Listeners
The event listeners for various actions.
- app/Listeners/
- UserRegisteredEmailListener.php
Models
Models are obvious, but when we then integrate Services below which handle all the buisness logic etc which make the calls to the models we implement SOLID practices, the Controller, Console or other Service, which calls the service only accesses the model through it. Once these have been integrated please ensure you delete the User.php model file and ensure that you have followed the installation and config instructions.
- app/Models/
- UserMeta.php
- User.php
- Team.php
- Role.php
Notifications
These are all our emails that we need to send out to the users in the application. These are amazing since they use the power of Laravel's notifcation component.
- app/Notficiations/
- ActivateUserEmail.php
- NewAccountEmail.php
- ResetPasswordEmail.php
Services
Service structure allows us to keep the buisness logic outside of the models, and controllers. This approach is best suited for apps that may wish to integrate an API down the road or other things. It also allows for a highly testable structure to the application.
- app/Services/
- Traits/
- HasRoles.php
- HasTeams.php
- ActivateService.php
- RoleService.php
- TeamService.php
- UserService.php
- Traits/
Database
Please ensure that all migrations and seeds are run post installation. These seeds set the default roles available in your application.
- database/factories/
- RoleFactory.php
- TeamFactory.php
- UserFactory.php
- UserMetaFactory.php
- database/migrations/
- 2015_11_30_191713_create_user_meta_table.php
- 2015_11_30_215038_create_roles_table.php
- 2015_11_30_215040_create_role_user_table.php
- 2015_12_04_155900_create_teams_table.php
- 2015_12_04_155900_create_teams_users_table.php
- database/seeds/
- DatabaseSeeder.php
- RolesTableSeeder.php
- UserTableSeeder.php
Views
The views consist of as little HTML as possible to perform the logical actio
Related Skills
gh-issues
337.4kFetch GitHub issues, spawn sub-agents to implement fixes and open PRs, then monitor and address PR review comments. Usage: /gh-issues [owner/repo] [--label bug] [--limit 5] [--milestone v1.0] [--assignee @me] [--fork user/repo] [--watch] [--interval 5] [--reviews-only] [--cron] [--dry-run] [--model glm-5] [--notify-channel -1002381931352]
node-connect
337.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
oracle
337.4kBest practices for using the oracle CLI (prompt + file bundling, engines, sessions, and file attachment patterns).
tmux
337.4kRemote-control tmux sessions for interactive CLIs by sending keystrokes and scraping pane output.
