Learning Laravel blade standalone - model-view-controller

I'm pretty new with blade template building in Laravel and I'm planning to use it as standalone. What's the best way to learn blade template building perhaps for standalone?
What's the different components of blade template building and what's the data flow?

If you want to use without Laravel, then you could try my library.
https://github.com/EFTEC/BladeOne
Its stand alone, only one class and no dependencies (and mit license)
The docs about blade is here
https://laravel.com/docs/5.5/blade
The data flow is simple:
add all the libraries and dependencies.
creates all the
variables, collects information from $_POST,$_GET and such.
Load
and do all the operations, such as loading from the database,
inserting, doing some operation.
And finally, call the template and send the variables. The template must be called at the end of your script. Always.

Related

Mixing Blade and Twig templates in Laravel

I have a Laravel 5.5 project that contains a lot of views in Twig format. In order to support Twig, the project uses the rcrowe/twigbridge package.
This works, but it’s now the only project that I have which uses Twig. Everything else is on Blade. I would like to move this project on to Blade templating, too.
However, I can’t commit a lot of time to this project and do the entire Twig to Blade transition in one go (unless there’s an automatic translator that I should know about?). Therefore it would be helpful to be able to render both Blade and Twig within the same project, at least until the transition is complete. How can I do this?

Include the contents of a file in a Vue template without using a child component

I have a Vue component that contains some template sections that I want to reuse in some new components. These new components share the functionality of the original component via a mixin.
I am aware that one option would be to turn each of the template sections I want to reuse into a component itself. However, if I do this then I'll need to write a heap of new code to handle passing all the variables down and the events back up (there's a lot of them). Really I want it to behave like it is part of the parent component; like a php include().
Is there a straight forward way of doing this with Vue?
I'm using webpack (which came bundled with Laravel and I confess to not knowing an awful lot about) to compile the code, so I wonder if there is some way of doing it with that rather than with Vue itself.

Combine Backend and Frontend Development with Laravel, Patternlab, Atomic Design and Vue.js

I'm going to launch a new project with this two frameworks (I like):
Laravel 5
Vue.js
The Frontend developer prepares the HTML's in atomic design, generated with patternlab.io.
Now I'm looking how I can integrate the patternlab.io project that I don't have to rewrite all the elements in a blade template.
I found some implementations combining Patternlab & Laravel using TwigBridge, Laratash Laravel extensions.
But I've some thoughts:
In the blade templates there is: logic, conditions, loops,.... If I combine patternlab and laravel then I need to put all this in the patternlab project.
Because of using vue.js I need to add also these tags to the patternlab templates
So I think it's not the best choice to integrate the patternlab.io templates in the laravel project.
My idea was:
Frontend DEV uses patternlab to create the templates
Laravel automatically generates & imports the CSS Stylesheet generated in patternlab
The Backend Developers copy the patternlab - molecules manually in the blade templates and add their own logic
If the Frontend DEV make changes on CSS, it's fine - we'll run in no issues; after rerunning the laravel gulp process to update the css files we have the new updates.
If the Frontend DEV makes some changes on a html structure we need to manually adjust them.
Is there a better solution combining Atomic Design, Vuejs and Laravel? How do you deploy atomic design in your CMS?
In the last three Vue/Laravel projects we've created we'v stopped using PHP as a rendering engine all together and used Vue exclusively. Laravel is still a really great framework for writing business logic and apis in a clean testable way – but we've decided to never use blade again.
Typically the issue you run into when trying to create a JS rendered application with a PHP backend is the lack of server side rendering. To solve this problem I've turned to a new project out of the Vue community, Nuxt.js (I have no affiliation with them, just a happy developer). Nuxt lets you write vue components and have them be both server side rendered, and rendered in the browser after the initial page load.
This allows us to completely decouple all of the rendering responsibilities away from Laravel and keep it in a single location, so no need to do blade and Vue – it's all Vue.
The only downside is that you'll need 2 servers Node.js and PHP.

use boilerplatejs with codeigniter

What is the best way to use codeIgniter with BoilerplateJS? should I put the codeIgniter folder in a BoilerplateJS folder or the contrary? Or something else? Need to make an authentifcation page in codeigniter and redirect the application in boilerplateJS.
Thanks.
I tried BoilerplateJS with CI in the following way:
Basically this is including BoilerplateJS in CodeIgniter folder.
I included all the BoilerplateJS code except the index file in to a folder named public which is in the root folder of CodeIgniter. The index file is placed in the views folder and will be loaded by a controller. (See the image)
For this to work some file paths had to be tweaked.
File paths in boilerplatejs index file (boilerplate.html in my case) had to be changed as follows:
./libs/jquery/jquery-min.js >>to>> public/libs/jquery/jquery-min.js
./libs/underscore/underscore-1.3.3.js >>to>> public/libs/underscore/underscore-1.3.3.js
and so on.
In main.js requirejs path configurations should be changed to:
require.config({
//Let's define short alias for commonly used AMD libraries and name-spaces.
paths : {
// requirejs plugins in use
text : 'libs/require/text',
i18n : 'libs/require/i18n',
path : 'libs/require/path',
// namespace that aggregate core classes that are in frequent use
Boiler : './app/core/_boiler_'
}
});
And in your controller you can load boilerplatejs by: $this->load->view('boilerplate.html');
I was thinking of integrating BoilerplateJS and CodeIgniter and probably use codeignighter-rest server for some time.
If all goes well I will share the code within the week.
A sample project is available at: https://github.com/slayerjay/codeigniter-boilerplatejs
EDIT Adding my view on CodeIgniter and BoilerplateJS
Firstly I have not (yet) done any major projects with BoilerplateJS and Codeigniter. But I have done projects using CI and the CI REST Server and know BoilerplateJS in and out.
I do not have much experience with other PHP frameworks (I have meddled with cakePHP and some others) but for me CI helps me to organize my code according to MVC pattern in a clean way, and provides excellent helper libraries and documentation.
As the OP rightly said, authentication is handled best outside BoilerplateJS and this can be done nicely with something like ion-auth for CI. After the user is authenticated and the SPA is loaded, the rest of the calls will be handled by the CodeIgniter REST server.
In this case you won’t be using much of the View aspect of your MVC architecture, but CI’s models and helpers would be of great help.
If you just need a simple REST server you can go with some lightweight solution that just provides REST type routing, but in many cases you will need to interact with a database and do some data processing.
So if you have decided to have a PHP backend for your application, Codeigniter with the REST server is a good choice.

CodeIgniter input class outside codeigniter

I'm moving an app from flat file php to codeigniter and I'd like to integrate the two as much as possible before moving over completely. I'm looking to specifically use the input class outside of codeigniter but it looks like I'd also need to use the controller logic (to get access to input segments). Can anyone walk me through using the input library in a flat file php?
I think you're creating too much work and potential problems by trying to do this. You'll be better off if you go directly to CI. Move any standalone functions in your standard PHP files into Helper functions.
If you really want to do this, you could use CI and create controllers/functions for all your files, then in the controller functions, just include() your PHP file and ignore the models and view for now. That way you'll have access to all the CI variables, including the $this->input data.

Resources