News for hackers. Stuff that matters.
Re:PHP in 2020 by CiPHPerCoder on Tuesday January 21, 2020 @05:30PM (#22112406)
> If you want to use packages then you'll need to use a Package manager, you still need command line experience etc.

PHP has a package manager IF you want to use the vast offering of open source PHP libraries and frameworks.

https://getcomposer.org/download

To use it, create a composer.json and run:

  php composer.phar install
On my systems, I like to alias it so that I just have to type:

  composer install
Alternatively, if you use a Jetbrains IDE (i.e. PHPStorm), you can usually install dependencies with one click.

> And to be fair, as a naive non-PHP user, I have 0 clue how you would go about setting up long running scripts that don't necessarily correlate to a web request.

php /path/to/script.php

It can run as long as you'd like.

If you want to do it on demand (i.e. writing a webserver in PHP), that's difficult. But generally: Why would you want to do that? It becomes an X-Y Problem.

Re:PHP in 2020 by fbernier on Tuesday January 21, 2020 @08:59PM (#22113841)
I don't think the person you're replying to said it was not possible with PHP. Just that similarly to other languages where it's just as straightforward as the example you gave, it's not built-in.
Re:PHP in 2020 by CiPHPerCoder on Tuesday January 21, 2020 @09:02PM (#22113860)
They said "I have no clue how to X" so I told them how to X, with caveats for corner cases.

I wasn't trying to debunk a claim that something is impossible.

Re:PHP in 2020 by stickfigure on Tuesday January 21, 2020 @09:58PM (#22114165)
so I told them how to X

No, you didn't.

What you probably meant is "run it from cron, or create an OS service that starts from init.d/systemd/whatever". Which answers the question, but isn't very impressive from a technology stack.

Re:PHP in 2020 by CiPHPerCoder on Tuesday January 21, 2020 @11:40PM (#22114689)
No, what I meant is: Run this command. It can run for as long as you want it to. That's a long-running process, by definition.

If they wanted something more specific, they should ask for what they really want.

Re:PHP in 2020 by Piskvorrr on Wednesday January 22, 2020 @05:10AM (#22116146)
Except that "PHP is meant to die", i.e. doesn't perform well as a long-running process, you'll keep running into bugs and warts. Software Gunslinger has explained that well: https://software-gunslinger.tumblr.com/post/47131406821/php-...
Re:PHP in 2020 by penagwin on Wednesday January 22, 2020 @09:25AM (#22117756)
I kinda meant both. I feel silly not knowing that it's only "php ./script.php".

I also meant long-running processes, which it sounds like is still problematic. To be fair, it doesn't sound like PHP was ever designed to be used for long-running processes, to which I guess "Fair enough", but that might make things like a job worker queue more complicated if you want to write the workers in PHP (it sounds like you'll need a dispatcher in a different language because that would be a long-running process).

Re:PHP in 2020 by r34 on Wednesday January 22, 2020 @11:42AM (#22119081)
This article is from 2013 and is not relevant anymore. Dozens of concepts useful even for writing desktop apps with PHP (I don't claim that it is the best choice) were presented in book "PHP Beyond the Web".
Re:PHP in 2020 by Piskvorrr on Wednesday January 22, 2020 @12:46PM (#22119953)
Not saying it's not possible: from where I am in 2020, long-lived PHP 7.4 processes still exhibit the described symptoms (memory leaks, even segfaults). In other words, tools for the job.
Re:PHP in 2020 by CiPHPerCoder on Wednesday January 22, 2020 @03:13PM (#22121520)
Memory leaks don't surprise me. Segfaults do.

Have you reported them upstream? That implies a memory safety or garbage collection bug.

Re:PHP in 2020 by Piskvorrr on Wednesday January 22, 2020 @04:49PM (#22122413)
Yup, GC bugs, mostly; some fixed, some are hard to repro...