We’ve just released a first “alpha” version of a package called ThemeDownloader – need your opinion, feedback and requests for future improvements. Basically, you can get a Bootstrap-based front-end theme into your Laravel project, just by launching one Artisan .

Without a theorical explanation, let’s see it in action.

Theme 1. Landing Page

Let’s say we have a fresh Laravel .5 installation with this view.

laravel new installation

Now, we install our package and launch the command to download the theme called Landing Page:

Here’s the result:

laravel theme download

Now, we have a new set of files in resources/views/landing-page folder, leading with a new welcome.blade.php:

laravel resources views

Now, all we need is to change our routes/web.php and apply our newly created Blade file:

And here we go – our Laravel homepage looks like this:

laravel landing page

Now, this package only downloads the front-end files and converts them to Blade language, but it doesn’t add any back-end logic. So, in this case, sign up form won’t work and other links won’t be clickable, you need to customize it yourself. But it helps you to have Blade structure and not to worry about it.

What package also does is downloading the related assets (CSS / JS / images) to public/vendor folder, also putting them into a separate theme folder to avoid conflicts:

laravel public landing page folder


Theme 2. Classimax – Classified Directory

We start by supporting two themes in our version 0.1.

So another Bootstrap-based theme we support is Classimax – a classified directory of companies, but technically you can apply it to any marketplace / e-shop / catalog.

We’re launching the same command, just with a different theme parameter:

And this theme is more complicated than just one landing page – it has multiple pages, with included partials and more assets. So it takes longer to download, but then we have this in resources/views/classimax:

laravel classimax views

And also quite a lot of images in public/vendor/classimax:

laravel classimax images

In this case, we also have a new ClassimaxController.php file and routes/classimax.php:

Finally, in routes/web.php the package adds this one line:

Notice: of course, you can change the logic how this route file is loaded – by just copy-pasting its routes to main routes/web.php or registering it in RouteServiceProvider.

As a final result, we have this page:

laravel classimax homepage

In this case, all the links should be clickable, but each of them represents just static page without any logic – here’s ClassimaxController.php file:

So it’s up to you to add your logic for the directory or remove any unnecessary pages.


Where does it all come from?

You probably wonder how we download themes and how it all works, in general. It’s pretty straightforward, actually.

1. We’ve downloaded both themes from their official sources and put into a separate repository:

laravel themes repository

2. When running Artisan command, we perform Guzzle request to our files – Github gives us public URLs for them.

Basically, that’s it.

The idea is that future themes, if any, will be added to that separate repository, and in case of theme changes, again – we can update that theme repository, without updating the main package.

Though, actually, for now it’s not that flexible – current two themes are “a little hard-coded” in version 0.1. We will wait for the feedback from the community before proceeding with more themes.


Speaking of which, we need your opinion! So please try out the package and put in the comment below in the form, we will appreciate it!

Any more themes you would like us to support? Or maybe you’re a theme creator which you want us to adapt to Laravel?

Link to the package again: https://github.com/LaravelDaily/theme-downloader

Want more tips and articles like this?

20-50 useful links every week on our weekly newsletter – comes out every Thursday!



Source link
thanks you RSS link
( http://laraveldaily.com/-v0-1-apply-bootstrap-theme-artisan-command/)

LEAVE A REPLY

Please enter your comment!
Please enter your name here