4 ms·
Any programmers here who've used PHP to build command line tools in PHP? What is the experience like compared to, let's say Python or node.js? How good are the
by mekoka 3y ago
Any programmers here who've used PHP to build command line tools in PHP? What is the experience like compared to, let's say Python or node.js? How good are the facilities? What are the limitations?
- muglug 3y agoI have rewritten more-or-less the same tool, 100KLOC, in Rust and PHP. I can't tell you about Python or Node.js Use PHP if - you're in a hurry and you already either know PHP, or the script is going to call other PHP code you've written - execution speed is not important (ditto for Python and Node) If neither of the above is true, give Rust a whirl.
- naiv 3y agoSymfony command is great for this https://symfony.com/doc/current/console.html https://symfony.com/doc/current/console.html But it really depends on what you need the command for. I use Symfony command for general things, Node.js for eg PDF generation, Python for ML, Rust for calculating Ranks/Scores Development time is the same for all of them. For whatever reason Node.js scripts always feel dirty to me. I can not even pinpoint why.
- porker 3y agoIt's really good. Using the Symfony Console component you get sane argument and option parsing and validation (optional/required, single or array values), output styling, interactive inputs, tables etc. If you're wanting to build a TUI I haven't seen any libraries as advanced as the Python or JS ones.
- pkphilip 3y agoVery easy to do. Check out the getOpt function for argument parsing etc.
- nunodonato 3y agohere's a nice goodie https://github.com/nunomaduro/termwind https://github.com/nunomaduro/termwind
- demurgos 3y agoI tried to write a CLI tool for orchestration by wrapping some sub-processes. I found PHP very limited in its ability to handle subprocesses (streams, error handling, signal forwarding). I tried to avoid using frameworks, but eventually used Symfony's "Process" lib. It helped with Linux but Windows support is very limited. This experience was pretty disappointing, but also pretty niche. Overall I agree with the general sentiment that PHP is very nice to use nowadays, especially for web development.