How to use codeigniter baseurl in php desktop, I used localhost but it's not working

1,823 views
Skip to first unread message

saikrishna rksoftline

unread,
Feb 4, 2018, 3:11:15 AM2/4/18
to PHP Desktop
Hi, 
I am new to this application, I tried to convert my codeigniter web application to desktop application. I copied all my web application data to php desktop chrome www/ folder. I changed database as per blog instruction. 
After compile my application Design not be work as well script also not working. I used url like this "http://localhost/applicationname/" . Can you please help me. I was struggling here.

Czarek Tomczak

unread,
Feb 4, 2018, 3:45:22 AM2/4/18
to PHP Desktop
Try using path without domain name, e.g. "/applicationname/". By default phpdesktop runs on a random port e.g. 65531 and is accessible in such case via http://127.0.0.1:65531/ . To disable random port edit settings.json file, see the Settings wiki page and the "web_server" section. If you set port to 80 then it will be accessible always using a fixed url like http://127.0.0.1/ .

Czarek Tomczak

unread,
Feb 4, 2018, 3:46:42 AM2/4/18
to PHP Desktop
Note that setting port to 80 is not a good idea if you're going to distribute app to other users, as this port may already bo taken and will result in broken app.

saikrishna rksoftline

unread,
Feb 4, 2018, 7:09:14 AM2/4/18
to PHP Desktop
In codeigniter Redirection and Routes are not working. Is there any way to resolve this. 

info.fx...@gmail.com

unread,
Feb 22, 2018, 1:26:55 AM2/22/18
to PHP Desktop
I've tried it with codeigniter 3.x and it works without problems:

In the file config.php:
- base_url = empty
- index_page = empty

In the autoload.php file:
- helper = url

In the file config.json:
- web_server> 404_handler = /index.php

In the external htaccess:
- RewriteEngine on
- RewriteCond $ 1! ^ (Index \ .php | images | robots \ .txt | assets)
- RewriteRule ^ (. *) Index.php / $ 1 [L]

The links are left only by placing the driver and the parameters if required:
- <p> <a href="Test?id=unID"> Go to show </a> </ p>

nosakh...@gmail.com

unread,
Mar 25, 2018, 10:32:03 PM3/25/18
to PHP Desktop
Hey Bro,
how did you do it...

Can u please give a detail of how u made it work, still struggling with mine.

Thanks for feedback

info.fx...@gmail.com

unread,
Mar 25, 2018, 10:50:23 PM3/25/18
to PHP Desktop
What's up friend!

It was as simple as copying all the files in the www folder of phpdesktop, and making the configuration indicated above, I explain:

In the config.php file of codeigniter, the base_url left empty just like the index_page.

Then in the file autoload.php of codeigniter just place the url helper for the test, then you can load what you need.

In the config.json file of phpdesktop, in the line of web_server> 404_handler, place index.php

And the file htacces of the root of codeigniter leaves it with the following configuration:

RewriteEngine on


RewriteCond $ 1! ^ (Index \ .php | images | robots \ .txt | assets)

RewriteRule ^ (. *) Index.php / $ 1 [L]


And with that I'm running without problems, I've even used it to show locally, websites and demo applications to customers.

I hope I helped you with this. regards

dattatra...@gmail.com

unread,
Sep 21, 2018, 4:50:19 AM9/21/18
to PHP Desktop
In the file config.php:
- base_url = empty
- index_page = empty

In the autoload.php file:
- $autoload['helper'] = array('url', 'file');

In the file setting.json:

quadri...@gmail.com

unread,
Jun 28, 2019, 5:25:24 AM6/28/19
to PHP Desktop
I'm trying to send AJAX request from a codeIgniter App running on PHPDesktop, i got the following error

XMLHttpRequest cannot load http://localhost/product/product_data. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1' is therefore not allowed access.
send @ jquery-3.2.1.js:9566

Czarek Tomczak

unread,
Jun 28, 2019, 6:27:25 AM6/28/19
to PHP Desktop
Please create your own topic for your issues. 127.0.0.1 and localhost are different origins thus web security restrictions apply.

saji...@gmail.com

unread,
Oct 10, 2019, 8:43:33 AM10/10/19
to PHP Desktop
simply open your config.php and set base_url as

$config['base_url'] = 'http://'.$_SERVER['REQUEST_URI'];

this will automatically set the baseurl depends upon the php desktop app's url

saji...@gmail.com

unread,
Oct 10, 2019, 8:43:58 AM10/10/19
to PHP Desktop
open config.php and set base url to
Reply all
Reply to author
Forward
0 new messages