如何自己开发微网站,做网站有几种语言,大连建设公司网站,杨谦教授编的营销课程目前#xff0c;较为成熟的技术是采用laravelS组件#xff0c;注意和laravel 区别laravelS多了一个大写的S#xff0c;由于laravelS默认监听5200端口#xff0c;所以laravel项目要做一些调整 例如#xff1a; 静态文件引入的方式-----从静态资源服务器加载我们熟悉的js和c… 目前较为成熟的技术是采用laravelS组件注意和laravel 区别laravelS多了一个大写的S由于laravelS默认监听5200端口所以laravel项目要做一些调整 例如 静态文件引入的方式-----从静态资源服务器加载 我们熟悉的js和css引入方式还是通过相对路径引入到标签中但是如果集成了laravelS组件这种技术方案就行不通了网页不会加载样式或js文件所以我们最好采用从静态服务器加载相关文件的方法。文件laravel5.8官方手册给出了URL::asset()方法引入但是例子都过于简单如果我们静态文件的目录发生改变则官方文档中的案例就不再奏效 不过放心虽然“从静态资源服务器加载“听起来要写一些代码实现跨域加载似的但实践起来并没那么麻烦 项目结构 ngixn 分站点设置 server {listen 88;server_name yinti.com;root /dingshub2/yinti/public;index index.html index.htm index.php;location / {# WordPress固定链接URL重写 #这段显得尤为重要---如果没有laravel路由方式访问会提示404try_files $uri $uri/ /index.php?$query_string;if (!-e $request_filename) {rewrite (.*) /index.php;}}# PHP配置location ~ \.php$ {fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;include fastcgi_params;}#静态文件服务器的实现location ~ .*\.(gif|jpg|jpeg|png|js|css)$ { expires 24h; root /dingshub2/yinti/public/static; proxy_store on; proxy_store_access user:rw group:rw all:rw; proxy_temp_path /dingshub2/yinti/public/static;#静态文件访问路径比起域名下的根路径多了一层/static没错遇到诸如.css结尾的请求会到这个路径下搜寻 proxy_redirect off; proxy_set_header Host 127.0.0.1; client_max_body_size 10m; client_body_buffer_size 1280k; proxy_connect_timeout 900; proxy_send_timeout 900; proxy_read_timeout 900; proxy_buffer_size 40k; proxy_buffers 40 320k; proxy_busy_buffers_size 640k; proxy_temp_file_write_size 640k; if ( !-e $request_filename) { proxy_pass http://127.0.0.1;#默认80端口 } }
} blade模版文件中的引入 官方文档没有给i出详细交代不过我们可以利用一些laravel的配置功能达到我们的目的实现静态文件引入的“动态”化以应对静态文件路径发生改变的业务场景例如我们知道laravel在config文件夹下定义了若干php文件每个php文件中都返回了一个关联数组每个数组的键都对应了一个配置方案例如我们可以在config下定义一个名为(名称随意)staticfiles.php文件内容如下 #staticfiles.php?php return [_css_http://yinti.com:88/mycss,_bstr_http://yinti.com:88/booststrap4/css,_pic_http://yinti.com:88/mypic
]; 或者我们可以在.env文件中定义添加 MYCSShttp://yinti.com:88/mycss
MYPIChttp://yinti.com:88/mypic blade文件中这样引入 母版文件局部
!doctype html
html langen
headmeta charsetutf-8meta nameviewport contentwidthdevice-width, initial-scale1, shrink-to-fitnometa namedescription contentmeta nameauthor contentlink relicon href../../../../favicon.icosection(title)titleSticky Footer Navbar Template for Bootstrap/titleshow!-- Bootstrap core CSS -- #从config文件夹下的staticfiles.php文件中加载 link href{{asset(config(mystatic._bstr_)./bootstrap.min.css)}} relstylesheet #从.env文件中加载 !-- Custom styles for this template -- link href{{asset(env(MYCSS))./sticky-footer-navbar.css}} relstylesheet ........................剩余部分略去不表 模板继承文件 extends(masterpage.login)
section(title)title搏击运动员之家/title
endsectionsection(h1)h1 classmt-5搏击帅哥魏锐/h1
endsection
section(plead)p classlead2009年魏锐考入湖南吉首大学并因此成为河南周口市鹿邑县的第一名运动员大学生。 codepadding-top: 60px;/code on the codebody gt; .container/code./ppBack to a href../sticky-footer生活中的魏锐静若处子动若脱兔有如李连杰年轻时的俊郎外表和气质表情文静态度温和赛场上的他则如猛虎下山身形灵动一次次为梦想而“KO”/a minus the navbar./pp #从.env文件中加载 img width60% src{{asset(env(MYPIC)./9aa88827.jpg)}}/p
endsection 路由定义 Route::get(wr,function(){return view(sample.wr);
}); 效果 转载于:https://www.cnblogs.com/saintdingspage/p/11267518.html