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

johnDoe220's avatar

how to implement @yield and @section in php pure

I am going to implement in php a structure similar to @yield and @section like Laravel. I have nothing to do with the blade. I just want to know how to do this in php

0 likes
2 replies
AddWebContribution's avatar

Hi,

We can define @yield in the Main Layout, -- HTML headers ... @yield('css')

-- HTML Body @yield('content')

-- HTML footer @yield('javascript')

We can separate our javascript and CSS files for every single View in its own view file like this: // for example in main.blade.php @section('css') @stop @section('content') // content of main @stop @section('javascript') @stop

// and for another page, profile; for example @section('css') @stop @section('content') // content of the profile @stop @section('javascript') @stop

Please or to participate in this conversation.