Codeigniter assets folder best practice

后端 未结 3 803
我寻月下人不归
我寻月下人不归 2020-12-01 01:59

I\'m fairly new to codeigniter, But i\'m learning well, I\'m going to add a css, images, js, ... folder but I\'m not sure where to put it

Someone to

3条回答
  •  粉色の甜心
    2020-12-01 02:51

    another angle on this -- and i think what they were trying to tell you to do - is putting your application & system folders one level up from the "public" html folder. that way your source files are not accessible. so like in Mamp the public folder is called htdocs, in most web hosting its called html.

     /application/html/
     /system     /html/
    
     // your main index page is in the public html folder
     /.…..       /html/index.php 
    
     // an assets folder in the public html folder with css, img, etc folders
     /.……        /html/assets/css/
     /.……        /html/assets/img/
    

    then in your index.php, the path is going one level 'up' like

    $system_path = '../system';
    $application_folder = '../application';
    

    BONUS - here are two tips that have helped me a lot. 1) Name your application folder, then you can easily switch between different versions, 'roll back' very quickly, etc.

     /app_alpha/html/
     /app_beta01/html/
     /app_beta02/html/
    

    2) Put the base url on the index.php page -- not in the config.

       $assign_to_config['base_url'] = 'https://awesomedomain.com'; 
    

    that way you can have a local development version, separate live server version -- and you never have to worry about over writing the base url because its on the index.php page - not in the config.

提交回复
热议问题