drd43058 2017-03-30 11:26
浏览 45
已采纳

如何在Laravel中设置CodeIgniter中的assets文件夹

like the public folder given by laravel default i tried to create something like that for easy make up of my css, js, picture and so on. I tried configuring it like this. In my application/helpers/utility_helpers.php

    <?php
    function asset_url()
    {
  return base_url().'assets/';
    }
     ?>

I have my assests folder along with application, system, user_guide etc. i confugured the autoload function of application/config as :

    $autoload['helper'] = array('url','utility');

when i hit any url in browser now, it says

    An Error Was Encountered

    Unable to load the requested file: helpers/utility_helper.php

how can i make it and can you explain me if i need to specify root for that helpers also.And if not can i simply access the assets like this:

    <img src="assets/base_components/build/banner.png">

in my view

  • 写回答

3条回答 默认 最新

  • duanke6057 2017-04-20 17:58
    关注

    In fact the answer is very simple, you only need to put ../ before every file that is under assets folder, because the root of the codeigniter is in application folder, but how you can't put the assets folder there and for the best practices, let the structure of the project like below and apply this solution to the path of the files:

    Website Folder structure
    |---|application\
    |-------(CodeIgniter application folders...)
    |---|assets\
    |-------css\
    |-------images\
    |-------js\
    |-------robots.txt
    |---|system
    |-----(CodeIgniter system folder...)
    |index.php

    Path of the files
    ex.:
    CSS

    <link href="../assets/css/bootstrap.min.css" rel="stylesheet">
    
    <link href="../assets/css/plugins/font-awesome.css" rel="stylesheet">
    

    IMAGES and others

    <img src="../assets/images/build/banner.png">
    

    JAVASCRIPT

    <script src="../assets/js/jquery-2.1.4.js"></script>
    
    <script src="../assets/js/plugins/jquery.scrollSpeed.js"></script>
    

    Note.:
    Always remember to applay the best practices to the code too (this will help for the performance of the the page too), like below:

    <html>
        <head>
            meta tags
            favicons
            css files styles
        </head>
        <body>
            page structure code
    
            javascript files
        </body>
    </html>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料