[英]Laravel 8 Components without Blade
I have created a basic CMS (Content Management System) using Laravel 8. I am not using Blade.我使用 Laravel 8 创建了一个基本的 CMS(内容管理系统)。我没有使用 Blade。 All of my views are plain PHP and HTML.我所有的观点都是简单的 PHP 和 HTML。 At this point everything is working but I have a lot of redundant code.此时一切正常,但我有很多冗余代码。 Is there anyway to incorporate component like logic without using Blade?有没有在不使用 Blade 的情况下合并类似逻辑的组件? Should I just use PHP include statements?我应该只使用 PHP 包含语句吗? Is there a proper way to do this?有没有合适的方法来做到这一点?
For example, I would like to move my header HTML to a separate header.php
file.例如,我想将我的 header HTML 移动到单独的header.php
文件中。 This would include everything from the <!doctype>
tag to the <body>
tag.这将包括从<!doctype>
标记到<body>
标记的所有内容。
I'm not sure if this is the proper way to achieve this, but the view()
functions works from within a view file:我不确定这是否是实现此目的的正确方法,但view()
函数在视图文件中工作:
<?= view('layout.header') ?>
Anyone see any issues with this?有人看到这有什么问题吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.