Home > Backend Development > PHP Tutorial > Laravel中命名空间的运用

Laravel中命名空间的运用

WBOY
Release: 2016-06-20 12:57:50
Original
1845 people have browsed it

Laravel中自己封装了一个独特的命名空间,可以让开发者在View中能使用特定命名空间。

View::addNamespace('Theme', '/views/theme/');
Copy after login

那么我们就可以在View::make()中进行运用了,比如

return View::make("Theme::templates.message",array('message'=>'我是消息'));
Copy after login

因为添加了Theme的命名空间,那么在View::make中就会相应的查找/views/theme/templates/message.blade.php文件。


使用这种方法添加命名空间,简单粗暴。

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template