Welcome Guest, Not a member yet? Register   Sign In
Making auto detecting of base url to be compatible with composer
#1

(This post was last modified: 10-19-2019, 07:36 PM by Chivinsdev.)

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
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
Reply




Theme © iAndrew 2016 - Forum software by © MyBB