NotionCommotion Posted June 4, 2016 Share Posted June 4, 2016 I recently tried http://www.slimframework.com/ to set up a REST API. Easy. Is there any reason I should use it or some other similar product for a normal website navigation? Previously, I put complicated (at least to me) regex in my httpd.conf (or .httacces) files to make URLs pretty. The redirects when using Slim is just to send everything to index.php if it isn't real. Yea, I am sure if volume is high, it isn't ideal, but what about when just starting off? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/301296-should-slim-be-used-for-normal-website-navigation-instead-of-complicated-apache-redirects/ Share on other sites More sharing options...
Jacques1 Posted June 4, 2016 Share Posted June 4, 2016 I think what you're actually talking about is a routing engine. That's the part of Slim which is responsible for processing pretty URLs. You don't need a completey framework if you just want a router, there are plenty of standalone libraries. Are there any reasons for using a router? You already answered that question yourself: Yes, they let you get rid of low-level URL manipulations. Your remark about performance issues(?) I don't understand. Routers aren't ideal compared to what? The Apache rewrite engine? Quote Link to comment https://forums.phpfreaks.com/topic/301296-should-slim-be-used-for-normal-website-navigation-instead-of-complicated-apache-redirects/#findComment-1533416 Share on other sites More sharing options...
NotionCommotion Posted June 4, 2016 Author Share Posted June 4, 2016 I think what you're actually talking about is a routing engine. That's the part of Slim which is responsible for processing pretty URLs. You don't need a completey framework if you just want a router, there are plenty of standalone libraries. Ah, that is exactly what I want. Thanks! Do you have any recommendations? Have you tried any of the following? https://github.com/mrjgreen/phroute https://github.com/dannyvankooten/AltoRouter https://github.com/dannyvankooten/PHP-Router http://blogs.shephertz.com/2014/05/21/how-to-implement-url-routing-in-php/ http://www.kratedesign.com/blog/2010/03/php-router-and-clean-urls/ Your remark about performance issues(?) I don't understand. Routers aren't ideal compared to what? The Apache rewrite engine? Yes, compared to the Apache rewrite engine. Quote Link to comment https://forums.phpfreaks.com/topic/301296-should-slim-be-used-for-normal-website-navigation-instead-of-complicated-apache-redirects/#findComment-1533418 Share on other sites More sharing options...
Jacques1 Posted June 4, 2016 Share Posted June 4, 2016 Ah, that is exactly what I want. Thanks! Do you have any recommendations? Have you tried any of the following? I don't have any specific recommendations. Pick a project which is actively maintained by a group of developers (rather than code from a random website). This is a lot about personal preferences. Do you want your routes in a code or in an external configuration file? Do you want reverse routing, i. e. get URLs from routes? Yes, compared to the Apache rewrite engine. The native rewrite engine might be slightly faster than running PHP code, but this is just a small part of request processing. In any case, manually maintaining rewrite rules for a non-trivial site is a PITA. I remember one project which actually did that, and everybody regretted it. The only thing you should avoid is passing all requests to the router. Static files should be handled by the webserver itself. But since Slim appearently does that already, I don't see any problem. Quote Link to comment https://forums.phpfreaks.com/topic/301296-should-slim-be-used-for-normal-website-navigation-instead-of-complicated-apache-redirects/#findComment-1533421 Share on other sites More sharing options...
NotionCommotion Posted June 5, 2016 Author Share Posted June 5, 2016 Thanks Jacques1, For now, I just wrote my own router. One of these days, I will start using a framework, and am sure one is built in, so why get married to another. I would expect the Apache rewrite engine is significantly faster and maybe will save a billionth of a second. Glad I am not the only one who thinks it is a PITA, and I will concede this small performance advantage for less pain. Quote Link to comment https://forums.phpfreaks.com/topic/301296-should-slim-be-used-for-normal-website-navigation-instead-of-complicated-apache-redirects/#findComment-1533427 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.