Laravel with fully separate code

Asked

Viewed 137 times

0

I’ve been programming with PHP for some time now, and I’ve always done my projects at hand (without using framework like Laravel, zend, etc.), making a structure very similar to mvc. However I want to improve as a programmer and in view of new job opportunities I am trying to adhere to the best practices of the market, with this in mind I decided to start studying and use Laravel to develop my new projects. But when watching the video lessons and even the documentation I see that it is very common to use PHP together with HTML and ignore the existence of js. My question is: Is it wrong that I want (or not recommended) to use Javascrip, PHP with Laravel and leave everything separate, that is, on the page that will html will not go any other code than pure html? Or traveling and I need to get used to use php in msm page q html?

1 answer

0


It is not wrong to use in separate files.

The tutorials you should be looking at must be using the Blade Engine.

In the documentation of Laravel about the Blade he informs:

Blade is the simple, yet Powerful templating engine provided with Laravel. Unlike other popular PHP templating Engines, Blade does not restrict you from using Plain PHP code in your views.

It allows you to use PHP in views and describes this as a differential. You can handle all the code PHP in the Controller and use the Blade to handle data extracted from Controller.

Blade usage is optional. If you rename a Blade file, for example home.blade.php to home.php, it will work as a common php file.

It is also common to use Vue.js and Reactjs in projects Laravel, however are separate things, the tutorials you are seeing should possibly be focused on Laravel using only with PHP and Blade.

There is a part in the documentation especially for structuring JS files. JS structuring documentation.

  • I had not attempted to use the Blade, nor imagined that it used npm to manage the js framework. Thanks for the attention and attention

Browser other questions tagged

You are not signed in. Login or sign up in order to post.