-
Notifications
You must be signed in to change notification settings - Fork 28
Add an artisan make:view command #241
Comments
This would be a fantastic addition. For alternate formats though, I think it would be best to have a |
This is what I hoped to get implemented to. Also it would be nice to automatically be able to pass data trough from the eloquent model. This would then scaffold out the following view :
|
I'm not a fan of that @concept-core. It should be kept simple and clean without too much overhead. Your idea could be neat for a package or own seperate command on a per-app basis, but it wouldn't really fit in the main Laravel codebase in my opinion. |
@svenluijten hmm I think your right in the way you say that. |
I like this one:
|
What about this? I will write this command php artisan make:view posts --resource And generate a full set of necessary view files for a resource controller. posts/index.blade.php
posts/create.blade.php
posts/store.blade.php
posts/show.blade.php
posts/edit.blade.php
posts/update.blade.php
posts/destroy.blade.php |
@kingRayhan that might be overkill, most of the times from what I have seen at least the only thing you need are the following views. Note that the create and edit could include a format view which hold the main form for both edit and create. |
@concept-core BTW: I found a third party artisan command package exactly what was I looking for. |
+1 for baking this into core. |
Already made solution: |
@mikizdr Yep! This was mentioned in my original issue (last sentence), and in @kingRayhan comment here. Thanks, though 🙂 |
This command could balloon up with options pretty quick unless we intentionally limited the scope. I would personally limit it to a simple --extends switch... in a perfect world that would probably scan for @yields in that layout and automatically make sections for them in the newly generated view but that could be tricky? What if the yield is a variable... or some concatenated string, etc. |
@taylorotwell, limiting sounds a good way to go about this. Just a simple way to create view/resource views ( that where I would use it for ) would be sufficient I guess. Thanks for replying and taking the time to share your opinion. |
Yeah, sure, that's the most basic approach for sure. |
I feel like it doesn't need to be all that extensive. ( A year back I thought otherwise ) If I image that workflow along with the |
Yep, I feel like the options in AFAIK no other |
This sorta raises the point... if |
Hah, good point! If not pulled into core, I'll still be maintaining Artisan View (some help from the community is always appreciated 😉), and at the end of the day it's your call @taylorotwell. What does the rest here in the thread think? |
My 2 cents on this would be that I think a simple If I really need I can still pull your package in and use it. I guess this is really a taste thing. |
My two cents:
would be ideal. I think it could scope creep out of control so I'd be all for limiting to that basic functionality |
You can refer my tutorial: https://flipper.vn/tu-viet-lenh-make-view-trong-artisan-laravel |
Is this still something that could be implemented? I love this idea so much! I tried to do this on my own using |
@elijahcruz12 Just use |
It will be cool. |
Amazing, but if I create the same name blade, it would be replaced |
what that too. |
Adding a command like
php artisan make:view
would allow the user to generate view files via the command line instead of having to use their editor and/or filesystem.Some options that may be interesting:
php artisan make:view products.index
-- Generatesproducts/index.blade.php
.php artisan make:view index --extends="_layouts.base"
-- Extend an already existing view.php artisan make:view products.index --section="content"
-- Scaffold out a section.php artisan make:view products --resource
-- Generates an entire resource (products/index.blade.php
,products/edit.blade.php
,products/show.blade.php
&products/create.blade.php
).These features would of course be limited to blade-only. If someone is using Twig (or another templating engine), they might appreciate an option like
--extension
to set the file extension:php artisan make:view products --extension="html.twig"
I already have an implementation of this here which can be used as inspiration.
The text was updated successfully, but these errors were encountered: