Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Harti's avatar

Make Twitter Bootstrap optional

Heya,

I like how L5 is coming with a boilerplate for Twitter Bootstrap now. Alas, I've been working with Zurb Foundation for many years and am not currently planning to change that, and neither is my boss/work.

Foundation has one significant advantage over Twitter Bootstrap: It really only gives you the foundation to build something upon whereas Twitter Bootstrap does quite a bit more of fiddling with standard styling. Furthermore (but that is due to personal preference), I prefer Foundation's button - and generally "more flat" - style. But the most important thing is... I don't want my web projects to look like just about any other website, where every web developer knows - just by looking at it - "ah, this was made with Twitter Bootstrap".

If I want to exclude Twitter Bootstrap from upcoming Laravel 5 projects, in the best case I will have to delete the bower entry and rewrite all of the preset layout files. That is quite a lot of work for getting a "blank" L5 installation if you ask me. So I figured it could be a viable tradeoff to make the inclusion of Twitter Bootstrap completely optional, so that you require a different branch of L5 via composer and get the various layouts/partials installed.

Best would probably be some kind of package architecture where one could, for instance, write a Zurb Foundation style package that installed L5 with Foundation files instead of Twitter Bootstrap files.

I'm not sure what would be the best way to go, @JeffreyWay being a lot more experienced in these kind of things, so unfortunately I cannot constructively propose explicit changes to the planned structure. But I would still like to voice my concerns about the mandatory inclusion of Twitter Bootstrap. Are you really trying to make every Laravel project look the same?

/edit: PS: Searching for "Laravel 5 Bootstrap" yields a lot of false positives as posts referencing bootstrap.php will be included in the search results. :(

0 likes
29 replies
Harti's avatar

Thank you very much, I didn't know about this command yet.

But... not quite. It seems that it will remove gulp and elixir, and I don't want these to be removed as I'll need them when I include the Foundation SASS via bower.

chrisgeary92's avatar

Do you install Laravel often? If it's a one-off thing, then just do it manually, otherwise you could create your own command, save it as a package, then pull it in each time you start a new Laravel project. And run your custom command instead of the php artisan fresh one.

Harti's avatar

I've been using Laravel for about any private/university/work project, so I'm installing Laravel quite often, or "often enough".

Writing my own command and publishing it for the community may be worthwhile indeed, will certainly look into that unless a reasonable consensus is found. I just don't see why it should be up to Taylor and Jeffrey to decide which HTML/CSS framework is supposed to be used by the vast majority of Web Artisans - that is all. They could do the exact same thing and provide a php artisan bootstrapify command instead of asking everybody to use fresh.

chrisgeary92's avatar

Laravel has been biased toward bootstrap since 4.0 anyway (and possibly in 3.*). The default model pagination markup is for bootstrap (of course you can override this). The other advantage of using Bootstrap (from a beginners perspective), is that most of Jeffreys videos on Laracasts use Bootstrap, so it's more familiar for those beginners.. And those that are more advance, will know how to swap it out.

austenc's avatar

@chrisgeary92 -- I had wondered about this topic too, great to know about that command. I generally prefer grunt over gulp and was also worried about L5 being too opinionated about the frontend... I figured I'd wait to see what they came up with upon release, but it seems you've already answered my question! :)

1 like
pmall's avatar

It would be better without any boilerplate :) Or a scaffold command to install it.

3 likes
RemiC's avatar

I guess bootstrap is there because L5 ships with a authentication form out of the box ?

I don't like bootstrap too much (not following oocss, hard to customize, even in sass version) , but it seems the most used CSS framework, so that choice makes sense in a way... Now I just hope developers won't use it.

1 like
jrowe's avatar

Yeah, I don't use bootstrap either and I feel the command fresh would remove things that I still wanted in (auth controller/functionality).

1 like
sitesense's avatar

It's no big deal even if you install multiple times.

You really only need to do this once.

Simply customize bower.json, gulpfile.js and the blade views to your liking and save them somewhere, ready to drop into each install.

I'm pretty sure only beginners would keep those files as they are anyway, which is probably the whole point.

austenc's avatar

I'm all about making things easier for myself and other developers, but sometimes all the extra stuff (and the extra step needed to rip out things you don't need) isn't exactly ideal. One of the things I love (loved?) about Laravel was that it left a lot of those choices, specifically the frontend, up to the individual. So that your app had only the things you need and not much you didn't -- it grew with you.

There's a fine line between convenience and being overly opinionated on things like the frontend. I'd love to see the base framework remain with less of these types of choices made for you, and an official fork that is a ready-to-go all bells and whistles included type of thing. I'm sure Taylor has taken both sides of this coin into consideration, and I'm very much looking forward to the official release! Until then, I'll reserve my judgement on this matter. Laravel still kicks ass either way!

ATOM-Group's avatar

I've started architecting a package I'm tentatively calling "Boil" that is literally nothing more than an easy way to wire up your own boilerplate scripts, templates, and dependencies, (which themselves are independent packages designed to plug into Boil) and then storing all of these in a central public repository like packagist that anyone can contribute to and share their boilerplates.

The workflow would be to require Boilerplate in composer, then run something like php artisan boil:<name-of-boilerplate-package> and it gets a project up and running exactly how you want. Each boilerplate would have a simple bullet list of things it does a "recipe" if you will, and you could run boil with flags to skip certain parts of the recipe.

I have no plans to monetize this as a service, so if someone wants to take this idea and run with it, go for it. I am only doing this out of necessity as I've found it takes me about 4-5 hours on average to get most Laravel projects to where I personally want them before I can really start implementing custom business rules (that includes proper environment configuration, basic layouts, common packages, auth, auth-sessions, etc)

austenc's avatar

@tag, super cool idea! I think it makes more sense as a free developer tool though... not everything needs to be a subscription service. :) Wouldn't be surprised to see something like php artisan boil be integrated into laravel's core eventually... maybe even in 5.1? ;)

Either way, I think the bootstrap include is a welcome addition and look forward to L5 making my workflow more streamlined.

RemiC's avatar

Yes, something like yeoman integration would be awesome.

bestmomo's avatar

I like bootstrap (@RemiC not so hard to customize and it is a good base that saves time) but a php artisan boil would be a good add.

RemiC's avatar

Ok, I think I could elaborate... I'm a bit harsh with bootstrap, because I had a hard time with the Sass files last time I used it on a project. It lacks consistency, sometimes you have a fixed value, sometimes a mixin :

(taken from bootstrap variables.scss)

// Inverted navbar links
// $navbar-inverse-link-color: lighten($gray-light, 15%)
// $navbar-inverse-link-hover-color: #fff
// $navbar-inverse-link-hover-bg: transparent
// $navbar-inverse-link-active-color: $navbar-inverse-link-hover-color
// $navbar-inverse-link-active-bg: darken($navbar-inverse-bg, 10%)
// $navbar-inverse-link-disabled-color: #444
// $navbar-inverse-link-disabled-bg: transparent

I used to work with foundation and it uses mixins for nearly everything, so by only changing a few 'top level' variables, the rest of your stylesheet changes accordingly, with no 'leftover', which is much more elegant.

Apart from that I quite like it, the amount of resources & snippets on the web makes it really fast to work with, but I only use it when I know I don't have to customize it (~ backends) and use a prerolled theme.

2 likes
MThomas's avatar

@harti, did you pull-in L5 lately? Bootstrap is not part of it anymore...

There is no example app installed by default, probably you can add it in the future via an artisan command.

1 like
Harti's avatar

Thanks for the note, @MThomas - indeed I forgot to check prior to bringing this up again, sorry. Now that's a relief, though, provided it'll stay an opt-in thing :)

dberry's avatar

Why don't you just clone a fresh copy, set it up how you want it, then push it to your own repo and then clone that when you start your new projects? Then it's exactly how you want it. Simple & easy.

austenc's avatar

@dberry that works but merging changes from upstream can be a pain sometimes -- what if the base repository changes? Honestly I'm glad to see bootstrap go as a default (even though I use it in my projects!) as I think laravel should remain what it is, a PHP framework. If too many front-end choices are already made / setup as boilerplate, it's my opinion that those belong in an official fork. :)

1 like
fulup's avatar

I never notice Bootstrap was part of L5, even if many Laravel samples rely on it. I personally use Foundation-5, I must say that I choose F5 not because its was better than something else, but only because my 1st successful test with mobile phone browsers was based on F5, and that I'm too lazy to even think about trying something else.

To return to the original question, I'm wondering why any JS/CSS frontend framework should be embedded with L5. They are many thing that I would love to see in F5, like group and roles or a basic CMS backend, but a presentation fronted, why ? This being said a good documentation on best practice fot popular JS/CSS would be useful to many people. When I started with Foundation-5, I lost significant time before finding a model, where I could at the same time take advantage of "//cdnjs.cloudflare.com" while still keep and easy way to manage my SCSS customization.

By the way and somehow of topic, did people concerned by UI on small devices, noticed that the new Firefox for Developers now include adaptive view to simulate tablets and phones.

bashy's avatar

@tag You still running with that boil command? I'd be interested in hosting that

ATOM-Group's avatar

Work on it's been slow. For now I'm doing a poor man's solution (but arguably, a potentially better solution) that involves creating a bunch of boilerplate applications as forks of laravel/laravel. Then I just clone them, run composer install, change the git remote repository to the actual project I'm going to use, and then I'm done.

I still don't like this though - if I have a dozen or so boilerplate apps and I need them to be private, I don't want to eat private repo space to host them. But it works for now as a crutch.

1 like
dberry's avatar

@austenc, you keep a repository that is up to date and that is what you use for creating new projects. E.g., I have a "laravel-starter" repo that I use.

  • clone repo
  • rename origin laravel
  • add my new origin

then I can fetch laravel, merge my changes.

When I create a project, I just clone my "laravel starter" repo that has everything I use so I'm not having to do the same bootstrapping over and over.

austenc's avatar

@dberry, I understand that perfectly I was just stating that there may come a point when merging the changes won't be so trivial because of merge conflicts. Unlikely, but that's one more thing you have to deal with! That said, forking and doing what you said is the route I would take myself. Cheers!

Harti's avatar

So... with the imminent release of L5 I'd like to bring this issue up once more. It's a bit weird this discussion was paid little (official) attention to, and the previous suggestions such as php artisan fresh aren't working anymore. I cloned a clean L5 instance earlier, so I'm referring to the latest build that (no surprise, it's been in all recent episodes) does include Twitter Bootstrap for all the AuthController boilerplating.

My original concern still exists: For some projects I will certainly not mind using Bootstrap (and I sincerely appreciate it, and the AuthController, being there), but for most projects I would like to use Foundation. As of yet, there doesn't seem to be a "clean" way to remove Bootstrap from the Laravel instance ("clean" as in "doesn't take 10 minutes to remove everything manually" or "doesn't take days for a rather inexperienced developer to code his own command to do it automatically").

Removing Bootstrap requires the following steps:

  • remove resources/assets/less/bootstrap
  • remove @import command from resources/assets/less/app.less
  • remove/recompile public/css/app.css
  • add bower to package.json
  • add normalize.css and my frontend framework of choice to bower.json
  • run bower install/update
  • do quite a lot of tinkering with the gulpfile to get everything to work
  • run gulp
  • remove boilerplate views / replace current classes to make it look good again

That's too much for my liking.

Also, what's the deal with hard coding version numbers for html5shiv and respond.js within app.blade.php? Shouldn't people be including these via Bower (and mixing them via Elixir?) anyway, instead of retrieving them from an external CDN server?

I would kindly like to point out that I do not like where this is going, we're somewhat being "patronized" (for the lack of a better term) to abide by the best practices Jeffrey found useful in his daily business. Plus, why emphasize the use Composer so much and Bower (in combination with Elixir) so little?

I was really looking forward to learning how to manage all of my frontend dependencies like a professional, streamlining the process of updating jQuery and whatnot throughout all of my projects in a blink. But instead I'm facing a clear case of double standards, with Composer being praised and Bower being ignored... and on top of that, almost being forced to use Bootstrap and literally make every web application look like each other in the future.

mikebarwick's avatar

Bootstrap is mickey mouse. Period. Far more customization and easier work flow (and even the ability to limit code/features you won't use). Plus Zurb just released this...wow...instant boner: http://foundation.zurb.com/apps/

Bootstrap is paying catch up. Very disappointed with the bootstrap include, by default. Bad decision for a PHP framework on the rise...

2 likes
sitesense's avatar

You know, Bootstrap is kind of optional anyway. Very easy to remove.

With regards other options such as Foundation... whether you consider it better or not, it will never have the user base of Bootstrap (IMHO).

Bootstrap already has a plethora of examples, templates, themes and snippets that no other CSS framework will get close to for many years, if ever.

It is also so commonly included via CDN that it's "weight" could be almost zero - it's probably already cached, depending on your implementation.

Love it or hate it, I think it's the best choice if any framework is to be considered at all.

Please or to participate in this conversation.