Routes- Today i died - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Installation & Setup (https://forum.codeigniter.com/forumdisplay.php?fid=9) +--- Thread: Routes- Today i died (/showthread.php?tid=74393) |
Routes- Today i died - 5flex - 09-18-2019 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! 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. RE: Routes- Today i died - ciadmin - 09-18-2019 It sounds like you jumped in without reading the docs, or at least the right part of the docs. The user guide tutorial takes you through a complete simple app. The "default controller" is the name of the controller to look for if a controller is not specified in the URL; it is *not* the name of a subdirectory, nor is "public" the location of any controllers, nor is it a routing specification. What does go in "public" is the "front controller", index.php. This is not a true controller - it is some PHP logic to bootstrap the framework and trigger the framework's routing etc. This is standard practice. I know of no framework which behaves the way you describe RE: Routes- Today i died - includebeer - 09-18-2019 I don't think the problem is CodeIgniter! CI 3: https://codeigniter.com/user_guide/tutorial/index.html CI 4: https://codeigniter4.github.io/userguide/tutorial/index.html Google: https://www.google.com/search?q=codeigniter+tutorial+beginner RE: Routes- Today i died - Yuriy - 09-18-2019 (09-18-2019, 07:13 AM)5flex Wrote: Hello Dev's! Today i died!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/tutorial/static_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! RE: Routes- Today i died - unromantic - 09-18-2019 id you are died how can you you posted such a long thread think again you are alive buddy RE: Routes- Today i died - ciadmin - 09-18-2019 @Yuriy The document root should be "/var/www/html/example.com/public", without the index.php. I can't remember if it ahs a trailing slash or not. This is exactly what the CI4 installation directions say, for running a CI4 app. Hopefully this will revive @5flex too RE: Routes- Today i died - Yuriy - 09-19-2019 (09-18-2019, 05:50 PM)ciadmin Wrote: @Yuriy The document root should be "/var/www/html/example.com/public", without the index.php. I can't remember if it ahs a trailing slash or not.Thanks! I agree now because with index.php don't work style and js. So I have style files in public/css and js in public/js and svg in public/svg. Latest version: <VirtualHost *:80> ServerAdmin [email protected] ServerName server.part2 ServerAlias myDomen DocumentRoot /var/www/html/server.part2/public/ RewriteEngine On RewriteCond %{REQUEST_URI} !/index\.php/ RewriteCond %{REQUEST_URI} !/css* RewriteCond %{REQUEST_URI} !/js* RewriteCond %{REQUEST_URI} !/svg* RewriteRule ^/(.*) /index.php/$1 [L] ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> I'm sure you can write better but it works! |