Comments (4)
Thanks @mtvbrianking!
I think you could do this in a couple of ways:
Only require it in development: composer require mtolhuys/laravel-schematics --dev
You could alternatively provide a Middleware to the route through your config/schematics.php
file.
'middleware' => ['dev-env-or-something-similar'],
And then handle the check, block and/or redirect through the middleware.
from laravel-schematics.
The middleware option works just fine. I am leaving the steps here it could help someone else.
Create middleware
<?php
namespace App\Http\Middleware;
use Closure;
class NotInProduction
{
public function handle($request, Closure $next)
{
if (config('app.env') == 'production') {
abort(403, "Don't run in production.");
}
return $next($request);
}
}
Register middleware: app\Http\Kernel.php
<?php
namespace App\Http;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
class Kernel extends HttpKernel
{
// ...
protected $routeMiddleware = [
// ...
'dev' => \App\Http\Middleware\NotInProduction::class,
];
}
Protect routes; config/schematics
<?php
return [
// ...
'middleware' => 'dev',
];
You may need to clear the cache for the change to be effected.
php artisan config:clear
from laravel-schematics.
I had required in --dev
but I could still access the routes in production, I am just worried about users stumbling across the database schematics.
Let me write up a middleware to validate and restrict access based on the app environment.
from laravel-schematics.
Thanks for sharing @mtvbrianking !
from laravel-schematics.
Related Issues (20)
- Multiple namespaces HOT 7
- Support custom pivot models HOT 1
- issue with adding relationships HOT 6
- JsonLint Parsing Exception HOT 2
- Support for non-standard model directory path for DDD Laravel Sites HOT 3
- Reading from a custom path works, however when I try to add a field the POST to `/schematics/models/edit` HOT 6
- Support PostgreSQL HOT 4
- about create model HOT 2
- Very beautiful project, but here I still couldn't run HOT 4
- Stop working after somes tests HOT 3
- [Feature] Integrate into Pipe Dream File Factories for complete generation of all App fundamentals HOT 1
- Table prefix issue HOT 1
- [Feature] Support table name on create models (and migrations)
- [Feature] Create factory class
- [Feature] Support namespace models and controllers
- Creating Resource Controller when add Model HOT 2
- Schematics finds migrations but not models HOT 3
- Suport laravel 8? HOT 1
- Dynamic paths to create models
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-schematics.