CodeIgniter Forums
Making auto detecting of base url to be compatible with composer - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Feature Requests (https://forum.codeigniter.com/forumdisplay.php?fid=29)
+--- Thread: Making auto detecting of base url to be compatible with composer (/showthread.php?tid=74649)



Making auto detecting of base url to be compatible with composer - Chivinsdev - 10-19-2019

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


RE: Making auto detecting of base url to be compatible with composer - InsiteFX - 10-20-2019

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

// Should be written like this.
<img src="<?= base_url('public/images/logo.png');?>" /> 



RE: Making auto detecting of base url to be compatible with composer - Chivinsdev - 10-24-2019

(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