Hacker News new | past | comments | ask | show | jobs | submit login

Semi-related: what's the best place to learn the old school style of working with php, I already know laravel but it feels so far removed from normal php that I am not confident working with it on it's own.



0. Forget everything you know about php and programming in general really. 1. Make a simple web page in an html file 2. rename it to .php 3. then throw in some <?php ?> tags 4. Look up [include](https://www.php.net/manual/en/function.include.php) and not much more 5. PROFIT

At least that's how I remember writing php in high school.


I would try some "old style" php frameworks. Like CodeIgniter or Yii.

If you want even simpler, then maybe try Slim framework. You'll have to add your own data access lib.

If you want Grug brain PHP then there's https://github.com/bcosca/fatfree

You can also use composer package manager to build your framework with libs like routing, sql query builder, etc.


> Fast and clean template engine

Is PHP not already a template language?

The whole idea of PHP frameworks always confused me. Why do I need a router when I can simply add new files at the routes I want?


You're right, it is.

The advantage of a router is basically: please always execute this code (auth, db connection, logging, session, rate limiting, csrf protection) before running the actual code for pages that will be rendered.

Or you could also just keep using normal page.php files and possibly include a boot.php at the top of the pages to achieve the same. But then you don't get pretty URLs unless you're doing some server URL rewriting.

Come to think of it, routers require URL rewriting too.


Why not read the PHP docs and any tutorials they might have? The docs are pretty comprehensive.


Because they're mostly a vast array of reference docs with just one simple tutorial that barely scratches the surface?

https://www.php.net/manual/en/index.php




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: