9 ms·
PHP 7 makes life a lot better for PHP devs in many ways but one awesome thing is it obsoletes bunch of out-of-date tutorials by finally removing the old Mysql e
by trm42 11y ago
PHP 7 makes life a lot better for PHP devs in many ways but one awesome thing is it obsoletes bunch of out-of-date tutorials by finally removing the old Mysql extension \o/
http://php.net/manual/en/migration70.removed-exts-sapis.php http://php.net/manual/en/migration70.removed-exts-sapis.php
I actually met a young aspiring web developer who still learned DB-access with mysql_* functions. I urged him to switch to a sane framework like Laravel. Oh boy he was happy in a month and learned bunch of best practices quickly.
- imaginenore 11y agoThe problem with Laravel is, while being a sane framework, it absolutely kills the performance, especially the last version, which is now slower than Symfony. http://blog.a-way-out.net/blog/2015/03/27/php-framework-benchmark/ http://blog.a-way-out.net/blog/2015/03/27/php-framework-benc...
- mintplant 11y agoWow, they finally made good on their promise to remove ereg_*. I remember reading the deprecation notice on those functions (and using them anyway) maybe half a lifetime ago when I was first learning PHP.
- jamesoneill 11y agoI did the exact same thing back when I was first learning web development in 2012. All the PHP tutorials I used were really outdated but since I was new to it I had no way of knowing that. Thankfully I didn't get the chance to do any damage before I was exposed to modern best practices.
- arien 11y agoI think it's great to point new developers to the right resources. Besides sane frameworks, there are some good starting/best practices guides to help (that are regularly updated), such as: http://www.phptherightway.com http://www.phptherightway.com https://phpbestpractices.org https://phpbestpractices.org Also, I would encourage them to look at different frameworks, not just one. It'll help if they later move onto other languages, as they'll be already exposed to different ways of doing things :)
- mattmanser 11y agoIs phptherightway up to date? I only ask as scanning it I see that it recommends IIS7 for production PHP on windows servers. Which I believe you could only get using an unpatched windows 2008 server?
- arien 11y agoI don't use PHP on Windows, so I wouldn't know. But looking at php.iis.net and the PHP docs, everything points at IIS7 (or later), so perhaps that's the considered stable/supported version?
- y4mi 11y agowhile i cant comment on the validity of their advice, i can say with certainty that it is quite up to date. after all, the last change was just 2 weeks ago... "LAST UPDATED: 2015-11-16 16:19:03 +0000" (right below their banner at the top)
- teh_klev 11y agoI work for a shared hoster and can confirm that PHP works great on IIS6 (with FastCGI add-on installed) and IIS7+.
- mattmanser 11y agoYeah, but this is what it actually says: If you need to run your production system on Windows then IIS7 will give you the most stable and best performance. So it seems to be recommending IIS7 specifically, IIS 7.5, IIS 8 and IIS 8.5 have come out since then. So it is a bit like saying you should run this software on windows vista for best performance. IIS7 is old software. I guess I'm asking, have the IIS team given up on PHP performance or is this recommendation really out of date.
- teh_klev 11y agoThat page is way out of date. There's not really much IIS does other than hand off requests to a new or already warmed up php-cgi.exe (via the FastCGI bits). The performance stuff is really more down to the PHP maintainers (though Microsoft have contributed, and continue to do so). The only pain point can be when there's a new release of PHP and you have customers who want to access MS SQL databases. This is done via Microsoft's own drivers [0] (Windows only). It's not been unknown for these driver releases to lag a bit behind PHP releases, but that said I see they're on the ball now with support for 5.6. Other than that PHP runs just as quick and as reliably on Windows as it does on our Linux shared environments (I look after both). [0]: https://www.microsoft.com/en-us/download/details.aspx?id=20098 https://www.microsoft.com/en-us/download/details.aspx?id=200...
- aikah 11y ago> I actually met a young aspiring web developer who still learned DB-access with mysql_* functions. I urged him to switch to a sane framework like Laravel. Oh boy he was happy in a month and learned bunch of best practices quickly. There is some middle ground good practice which is using PDO, or even better Doctrine/DBAL . I don't think Laravel's ORM is that good, and the Active Record Pattern is somehow controversial.
- sbarre 11y agoI spent a good while trying to integrate Doctrine into my projects, and in the end I found it bloated and overly verbose and went back to PDO. I am sure that it has valid use cases, but for a lot of straightforward PHP projects, it's complete overkill and adds more work than it saves (in my opinion of course). I agree with knowing PDO though, I would say that's required knowledge for any self-respecting PHP developer.
- porker 11y ago> I spent a good while trying to integrate Doctrine into my projects, and in the end I found it bloated and overly verbose and went back to PDO. Were you integrating Doctrine, or were you integrating Doctrine/DBAL, as the parent poster recommends? Doctrine/DBAL is a bunch of useful helpers around PDO which take out a lot of the repetitive coding (and let me delete many home-grown methods I'd created to 'help' PDO)
- datasage 11y agoDoctrine is great for keeping rails on developers of various skill levels in large projects. But it does come at a cost of overhead. Most of the time for simple crud operations it doesn't matter, as long as you handle proxy generation and caching correctly. It can add up when you try to write code working on datasets. In those cases, I bypass doctrine and go direct to SQL.
- pc86 11y ago> Active Record Pattern is somehow controversial. What is controversial about AR?
- Scarblac 11y agoI am an experienced programmer but I've only touched PHP a few times, years ago. What are the best books or tutorials to get an overview of modern PHP?
- ryan-allen 11y agoI think the question is why should you bother with PHP at all? It had its time in the history of the web but that time has passed, long, long ago.
- jacquesm 11y agoWhat would you use instead and why?
- Scarblac 11y agoWordpress alone runs 25%+ of all websites. PHP's time is clearly still now. I probably won't bother with PHP, but it can't hurt to keep my idea of what it's like up to date. It's only technology, no need to be fanatical about it.
- sneak 11y agoJust because a lot of sites run it doesn't mean it's not crap. A lot of companies still host stuff on Windows like it's still 2002, as well. PHP has no place in modern development.
- deleted 11y ago[deleted]
- Killswitch 11y agoYou do realize that the number 2 ranked website on the internet runs on PHP. Get over your elitest attitude. PHP is a fine language and has it's warrants of use. Speaking of, 2 days ago marked a year since I last used PHP.
- ethnt 11y agoThat's how it's taught at the college I go to. About half the class already had experience with PHP/MySQL, and were a bit horrified.
- nnq 11y ago> I urged him to switch to a sane framework like Laravel ...why didn't you taught him about PDO, so he can start with something more universal, not tied to one particular framework that happens to be popular nowadays?! Then he can learn whichever OR/DM or DAL he might like need (Eloquent, Doctrine, Redbean, IdiORM/Paris etc.), and also be able to pop the hood and debug it when needed. I never get it why so many otherwise-good PHP devs have their heads full of framework-specific knowledge and have a propensity to fall in love with heavy frameworks like Laravel, or worse, with leviathans like Symphony or Zend ...instead of playing to the language's advantages and using light-weight tools and libraries that would allow them to move faster.
- trm42 11y agoI could've done that but that wouldn't have taught the same things. PDO is awesome but requires deeper level of understanding (for a beginner), which may increase the frustration and may end up returning back to the mysql_query and co. It's easier point to framework that's already using PDO and and making sane defaults and solving bootstrapping problems. Once you've learned bunch of new concepts like ORM in one framework, it's easy to understand other ORs and be able to compare it to DMs. My own experience with Laravel has been really positive. Actually I was thinking about creating something similar until I learned about Laravel, so it solved lots of existing annoyances regarding PHP coding for me. Everybody needs to start somewhere and I believe that by nudging towards Laravel, my young friend'll learn more in the long run and in the meantime can concentrate on making services instead of writing home grown PDO helpers and custom routing libraries. They are problems that have been solved already multiple times. Also, Symfony and Laravel communities are encouraging and teaching about the better ways of doing things so that'll help him in the long run. In many small project it's more fun and more easier to use $favorite_framework instead of searching for reinvented wheel. There are cases when it's better to do more custom solutions but for many cases frameworks are just awesome
- reitanqild 11y agoAgree, then again there are different types of people. Some wants to learn from bottom up(analytic approach), others want to see cool stuff then tweak, modify, replace to find the limits (holistic approach). IIRC there is a tendency that young people prefer the holistic approach while teachers either are selected for or grow into preferring the analytical approach.
- sneak 11y agoUrge him to switch to a sane language instead. You are doing no one a service by advising them how to make using PHP suck less.
- superskierpat 11y agoMy final project in my php class last year was way better than it would of been due to one simple website : http://www.phptherightway.com/ http://www.phptherightway.com/ Edit: Posted this before seeing the other comments suggesting it already, dope
- deleted 11y ago[deleted]
- Scarbutt 11y agoaspiring web developer Did he already know javascript? if not, why didn't you point him to that instead?
- trm42 11y agoAt least he was aware of it but preferred to keep it in the browser side. He had already started building something based on old PHP tutorials, what could be more useful if he has some small site to build: A. Tell there's a nicer and easier way to do it in PHP with well thought framework B. Tell server JS is so awesome (and all the cool kids are using:), you just need to start completely from the beginning Introducing things gradually can help a lot and lessen the frustration. Nowadays he's really into Vue and React but still likes to handle backends with Laravel :) Also learning is one of those things that helps if the learning stuff isn't too far away from the skills you already have. Introducing too much at the same time makes learning more frustrating - especially if you want to get something finished instead of trying to multiple ways of doing the same thing.
- ck2 11y agoOh you can most certainly compile mysql right back into PHP7
- ceejayoz 11y agoSomeone who's using mysql_* functions is probably not compiling their own versions of PHP.