Welcome Guest, Not a member yet? Register   Sign In
Routes- Today i died
#4

(09-18-2019, 07:13 AM)5flex Wrote: Hello Dev's! Today i died!

Sorry for my bad English, I'm from Russia. I will try to write about my problem and tell you that I'm furious!  Angry Angry Angry

Today at early morning I power on my PC and start to read WEB about PHP Frameworks. I read a lot of articles. Very many. 

A lot of developers recommend CI as the easiest and most convenient framework with good documentation, simple code, and most importantly rich functionality. I downloaded it, installed it, and started writing code. In the directory / controller, I immediately created my directory / public and put there my START FILE, which, as I thought, would be the default controller. In write rule for route - $route['default_controller'] = 'public/homepage'; But! I always get 404 error. I read the documentation. Again. Once again. And more and more and more. I looked at hundreds of sites, asking how to make the default controller from a subdirectory .... I spent ALL DAY on it and read with tears in my eyes that CI does NOT support this feature! how? How? HOOOOOOOOOOOOOOOOOOOW CAN IT BEEEEEEEEE ?!!!!!!!!!! This is unbelievable! Such a simple thing and so many problems! What is the problem of realizing such an opportunity out of the box?

Now one and the same thought is spinning in my head ... How can I start building a new project on such a “cool” framework if I already encountered a problem at the INITIAL stage, the solution of which took a WHOLE DAY! What awaits me ahead? I don’t know .... Today I died. Huh Huh Huh
Sorry for my bad English, I'm from Russia too!
I have ubuntu 18.04 with apache (no XAMPP or LAMPP). And codeigniter 4 routes didn't work on ubuntu. But it worked on Windows with Openserver.
So I wasted a lot of time. And I have solved this problem just now.
Apache site directory is /var/www/html/ and for example I have CI4 project in example.com folder just like this /var/www/html/example.com . I need the work of external queries at http://example.com. But if I write http://example.com I watch different folders and files. I need write http://example.com/public - then I see my site but without css and js. And http://example.com/public/myController does not work. May be http://example.com/public/index.php/myController will work...
I did the following:
--sudo nano /etc/apache2/sites-available/example.com.conf
and wrote like this:

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/html/example.com/public/index.php
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

--sudo a2ensite example.com
--sudo service apache2 restart
why?
https://codeigniter4.github.io/userguide...pages.html
Running the App
Ready to test? You cannot run the app using PHP’s built-in server, since it will not properly process the .htaccess rules that are provided in public, and which eliminate the need to specify “index.php/” as part of a URL. CodeIgniter has its own command that you can use though.
So,
DocumentRoot /var/www/html/example.com/public/index.php
is given “index.php/” as part of a URL.
It is worked!
Reply


Messages In This Thread
Routes- Today i died - by 5flex - 09-18-2019, 07:13 AM
RE: Routes- Today i died - by ciadmin - 09-18-2019, 07:43 AM
RE: Routes- Today i died - by includebeer - 09-18-2019, 11:21 AM
RE: Routes- Today i died - by Yuriy - 09-18-2019, 12:58 PM
RE: Routes- Today i died - by unromantic - 09-18-2019, 03:09 PM
RE: Routes- Today i died - by ciadmin - 09-18-2019, 05:50 PM
RE: Routes- Today i died - by Yuriy - 09-19-2019, 01:12 AM



Theme © iAndrew 2016 - Forum software by © MyBB