• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Making auto detecting of base url to be compatible with composer

#1
Hello I love detecting my base url automatically which I discovered not compatible with composer base on http and at the same time not compatible to public file assets including such as:


PHP Code:
<img src="base_url('public/images/').'logo.png'" /> 

And here is my modification of app/Config/App.php

PHP Code:
public function __construct()
{
$root = (isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && ('on' == $_SERVER['HTTPS']) ? "https://" "http://") . $_SERVER['HTTP_HOST'];
$root .= str_replace(basename($_SERVER['SCRIPT_NAME']), ''$_SERVER['SCRIPT_NAME']);

$this->baseURL $root;



Please can you make this compatible with compser it is not working for
PHP Code:
php spark 
which is composer command
Visit Chivins.Com For Free Tutorial on Codeigniter
Reply

#2
PHP Code:
// Wrong!
<img src="base_url('public/images/').'logo.png'" /> 

// Should be written like this.
<img src="<?= base_url('public/images/logo.png');?>" /> 
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#3
(10-20-2019, 12:14 PM)InsiteFX Wrote:
PHP Code:
// Wrong!
<img src="base_url('public/images/').'logo.png'" /> 

// Should be written like this.
<img src="<?= base_url('public/images/logo.png');?>" /> 
Sorry that was a typo mistake
i meant this
PHP Code:
<img src="<?php echo base_url('public/images/');?>logo.png" /> 
Even on this there is still error
Visit Chivins.Com For Free Tutorial on Codeigniter
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.