It's becoming kind of an Enterprise language [1]. Don't get me wrong I think PHP is getting cooler, hopefully everybody catches up and the fact that You can have a shared hosting for pennies run Your PHP code really puts it at an advantage compared to others. [1]: https://github.com/joaomilho/Enterprise
> It's becoming kind of an Enterprise language It tried for decades to be one with Doctrine, Symonfy and co, trying to copy the worst of Java EE with every single possible design pattern implemented in these frameworks, XML configuration files and co... The problem is no generics, no private packages makes PHP OO a horrible mess compared to Java (or C#).
PHP 8: Before and After
91–100 of 346 posts
Re: PHP 8: Before and After
#92Re: PHP 8: Before and After
#93Seriously, enough with PHP. Can we just let it die? I worked with PHP 5.6 years ago and I hated it. Recently I worked with PHP 7. Heard about all the work that's been done on it and I was kinda excited to try it. It's still so broken. It doesn't matter if they improve performance or add new cool features. PHP is broken in ways that can't be fixed without breaking compatibility. Fork it or put it out of its pain.
I have worked with PHP for years, and I agree completely. I think the people who defend PHP either have too much invested in it, or they have never gotten productive in a saner language. Or both.
Re: PHP 8: Before and After
#94Can a fellow geek knowledgeable in PHP gives me a few pointers? I have inherited a 12 year old PHP app written by 2 interns. The code was written with Notepad++ (no IDE), no comments except when they copy pasted something from the internet, most variables are single letter and it's the biggest spaghetti bowl I have ever seen. To add insult to injury I have no experience with PHP (apart from peeking at this code to fi…
0. Ignore PHP8 for now. There's much more community support for PHP7, so fix it up to work on PHP 7.4 first.
1. My first task is always to use a code scanner to test if the codebase is PHP7 compatible (or PHP 5.6, or the next version on from whatever you're running). See https://blog.fortrabbit.com/php-testing for an incomplete list (I've used others but haven't got my bookmarks to hand). You'll get false positives but also a good feel for whether there are serious issues.
2. You don't say if it's a CRUD app or an API. If it's the latter: set up a PHP 7.4 box (with a copy of the datastore) and route all traffic to the current production box and to the copy. Save the responses from both and compare they're the same. A simple way to see if the app will work on PHP, and when you find something that's broken, you can fix it, reset the logs, and try again. Hard(er) to do with CRUD, but I have compared the datastore contents before to check they're the same.
3. Needless to say, stick it all in source control if it's not already.
4. For your own sanity, run a code formatter over it if the code is messy.
5. I like PhpStorm as an IDE. It's not free, but the intellisense and refactoring support (and the built-in debugger) are timesavers.
6. Assuming it's not global variables everywhere, that they've used functions/classes(!), then as you fix bits of the code rename the single letter variables and add comments. PhpStorm can refactor variable names, so you see what will change before it happens.
7. If the code's using mysql_* functions, which aren't present in PHP7, there's a shim to make them work: https://github.com/dshafik/php7-mysql-shim
8. Good luck! I like unpicking codebases like this and keeping them running. As a sibling commenter has said, it's an internal system so assuming staff are not going to exploit any vulnerabilities or you have guarded against those already, there is no problem keeping it running internally as-is. So long as you can still recreate the VM from scratch (I have had old packages disappear - now that makes for an interensting disaster recovery plan) and reinstall everything you need should backups fail, you're okay.
Re: PHP 8: Before and After
#95Earlier quoted context omitted.
Possibly not what the author meant. Support for PHP 8 in WordPress will come soon after PHP 8 is released. But to upgrade WordPress to PHP 8, that is to rewrite its codebase to make use of PHP 8 features, probably will not happen anytime soon. WordPress still has a minimum PHP version requirement of 5.6, so...
And thank fuck for that. WordPress is the only web framework I've found that approaches stability of the Linux kernel. Backwards compat is important and maintained. Gutenberg hurt this a bit but it still does a great job of maintaining backwards compat. I take old wordpress websites and update them and everything just works. I take old laravel or code igniter or Drupal sites update them and everything just fucking fa…
Drupal 5/6/7/8 intentionally broke backward compatibility between versions in order to move the architecture and the feature set forward. The net result is that they are now at a point where Drupal could drop PHP 5 support. They also moved towards modern PHP / coding practices over the past years (Not invented here -> Proudly found elsewhere, composer, PSR's, OOP,...).
WordPress stuck with preserving backward compatibility and so the core API's have never seen a fundamental breaking change between versions. New features have been tacked onto what was already there over time.
I have kept a personal WordPress blog since 2005 and I have always been able to easily update things without migration pains. Of course, I run a minimum of customized code (beyond a custom theme that is). And I suppose YMMV and you still might have a different experience, if you did heavy customization through plugins, heavily leaning on WP's core API's.
Drupal? Totally different experience. Breaking changes and fundamental alterations of the database schema have been par for the course. I've seen 6 month long migration projects to migrate crucial enterprise data between versions. The PTSD of migrating from Drupal 6 to 7 to 8 is real.
Then again, WordPress and Drupal are different tools despite a significant use case overlap. I'd be weary to use either Drupal for a simple blog, or WordPress for an intricate, tailored back office application. I think they are both designed to do different things all together.
Having said that, it's worth noting that the Drupal project is very aware of past pains. One of the big goals of the past few years was working towards avoiding big breaking changes between major versions. It is purported that migrating between Drupal 8 and 9 is far less painful. Of course, it remains to be seen how that holds up in the long term.
Re: PHP 8: Before and After
#96Seriously, enough with PHP. Can we just let it die? I worked with PHP 5.6 years ago and I hated it. Recently I worked with PHP 7. Heard about all the work that's been done on it and I was kinda excited to try it. It's still so broken. It doesn't matter if they improve performance or add new cool features. PHP is broken in ways that can't be fixed without breaking compatibility. Fork it or put it out of its pain.
This is such a shallow elitist comment. A lot of the common criticisms levied at PHP have been corrected years ago, and PHP is responsible for hundreds of billions of dollars of turnover globally. Of the top 10 websites in the world, PHP is partially or wholly powering more than half of them. Wikipedia, Wordpress, online retail. I have personally created 6 figures of value because I could quickly dump some PHP script…
They're actually great technologies, but for a very specific scope. Once you're outside of that strictly restricted scope, they're objectively horrible from an engineering point of view. The standard example is building a database with Excel + formulas.
There is a point in this whole thing. Some technologies should whither and disappear, slowly, over time, so that better one can take over. Or they should remain in their very narrow niches. For PHP I'd venture that it should remain a language for hobbyists creating personal home pages.
Related to this, standard, fixed column, steering wheels also were probably responsible for hundreds of billions of dollars of turnover globally.
But I'd still want my car to have a telescopic steering wheel, airbags, and all the modern safety features you find in a car.
The old school fixed column steering wheel should only be seen in museums or in classic cars out on the road with a special license.
Re: PHP 8: Before and After
#97Can a fellow geek knowledgeable in PHP gives me a few pointers? I have inherited a 12 year old PHP app written by 2 interns. The code was written with Notepad++ (no IDE), no comments except when they copy pasted something from the internet, most variables are single letter and it's the biggest spaghetti bowl I have ever seen. To add insult to injury I have no experience with PHP (apart from peeking at this code to fi…
Roughly in the order you should do it. Hopefully it's at least PHP 5.3 code: 1. Definitely get a PHP IDE: https://www.jetbrains.com/phpstorm/ 2. Get a step debugger and hook it in: https://xdebug.org/ 3. Fix the code style: https://github.com/FriendsOfPHP/PHP-CS-Fixer 4. Run the code through some static analysis tools https://phpstan.org/ https://psalm.dev/ 5. Upgrade the code with an AST fixer (might help you update…
- Make sure you have version control. So easy to do these days, so often forgotten.
- don't think that the steps above must be done in order, right now.
- dkarlovi mentions tests. Start with 1.) smoke tests like simple selenium tests or something like that. You'll find lots of vate towards it if you look and I admit it has issues but for simple projects like this that doesn't change much it should be fine. Of course of you find something better use that.
- one of the most important things about a good IDE is being able to refactor confidently so you can rename variables to something reasonable as you figure out what they really are.
- the book "refactoring legacy code" might be the best programming book I've read.
Re: PHP 8: Before and After
#98Earlier quoted context omitted.
> This is such a shallow elitist comment. A lot of the common criticisms levied at PHP have been corrected years ago, and PHP is responsible for hundreds of billions of dollars of turnover globally. So does Java, Python, C and C++. This is also a shallow argument. No language is perfect but PHP still suffer from the same design issues a 10/15 years ago, none of them have been correct and it's perfectly valid to point…
PHP is a great fit for the web, always will be. There are “better” languages and solutions but they are usually more difficult to setup or not as easy to learn.
1) It used to be loaded straight into the Apache process as a module, which made it very convenient to get started with but required terrible broken hacks to run multiple applications/users separated from each other in a secure way. But nowadays people are switching to PHP-FPM, which is the same approach used by Python, Java and most other languages.
2) Every possible extension baked right into the language as a global function instead of using namespaces and a package manager like other languages. But nowadays people use namespaces and a package manager, just like in other languages.
3) Templating as part of the core language (in fact the core language is a templating language) so you don't need a separate templating library like in other languages. But nowadays people use separate templating libraries, just like in other languages.
Re: PHP 8: Before and After
#99Can a fellow geek knowledgeable in PHP gives me a few pointers? I have inherited a 12 year old PHP app written by 2 interns. The code was written with Notepad++ (no IDE), no comments except when they copy pasted something from the internet, most variables are single letter and it's the biggest spaghetti bowl I have ever seen. To add insult to injury I have no experience with PHP (apart from peeking at this code to fi…
IDE: Visual Studio Code with the PHP extensions, free. Compiler: you are looking in the wrong direction, PHP is interpreted. There were some compilers, but it's not what you need. Converting to PPHP 8: do you need that? what are you trying to achieve? You can keep the app another year or so it it is working, don't fix what is not broken. There is no way to convert to 8, you need to rewrite it, PHP become more object…
What I would like is an IDE experience: everything that isn't PHP8 compliant is underlined in red so I can fix the thing without launching the app every time and see if I broke something.
Re: PHP 8: Before and After
#100Earlier quoted context omitted.
The day you reach perfection is the day you finish your project as in never... PHP works (thought not perfect) lets me get things done.
Lots of languages work and let you get things done. You don't have to choose PHP.