DEV Community

Cover image for Why PHP?

Why PHP?

Roberto B. on November 24, 2023

Rediscovering the Strengths of PHP: Unveiling the Modern Ecosystem In the contemporary web development landscape, PHP's enduring relevan...
Collapse
 
bobbyiliev profile image
Bobby Iliev

Nice!

Collapse
 
robertobutti profile image
Roberto B.

Thank you @bobbyiliev ! If you have any feedback, feel free to share ✨

Collapse
 
mcharytoniuk profile image
Mateusz Charytoniuk

Totally agree. PHP is a mature language with a rich ecosystem. If the community embraces async extensions and long-running processes I think it will have a bright future.

Unfortunately I think it suffers from a lot of false misconceptions. I wrote about that here. Can you let me know what you think? dev.to/mcharytoniuk/programming-co...

Collapse
 
sanjayojha profile image
Sanjay Ojha

Nice update for those who still think PHP 5 is the way of making PHP app. I agree after PHP 7, PSR, Composer, and framework like Symfony and Laravel things have improved a lot.
But still use right tool for right job, Python is still better choice for data science, ML, scrapping, bots etc. I will chose PHP over anything else for web application. Node and any JavaScript frontend library to make app that requires high concurrency and modern Web APIs.

Collapse
 
robertobutti profile image
Roberto B.

Thank you for your comment. Totally agree to use the right tool for the right job. I'm a fan of PHP for web development, but depending on the context, I love using Go, Rust, Python, or Javascript (the choice depends on the type of the project). I am not ashamed to admit that in the past, when I was young, I also used Cobol and Visual Basic 🤣 .

Collapse
 
jordantylerburchett profile image
Jordan Tyler Burchett

PHP will always be my favorite language, there's just so much you can do without using so many external libraries

Collapse
 
sreno77 profile image
Scott Reno

Great post!

Collapse
 
otvoslaszlogabriel profile image
Otvos Laszlo Gabriel • Edited

Cool article ! I’ve enjoyed reading! No doubt that I will be doing more php work in the future.

Collapse
 
cesardevesa profile image
Cesar Devesa

We're in this together.

Collapse
 
tanzimibthesam profile image
Tanzim Ibthesam

Lovely article keep it up

Collapse
 
efpage profile image
Eckehard

I often struggle to write and debug PHP code, but sometimes it's the only simple option to access a database or to find files on the server. Are there any standard libraries or example repositories you could recommend to make my life easier?

Collapse
 
robertobutti profile image
Roberto B.

one great and free resouce is phptherightway.com/

another (paid) resource is front-line-php.com/

Collapse
 
efpage profile image
Eckehard

Great, Exactly what I need!

Collapse
 
kwnaidoo profile image
Kevin Naidoo • Edited

Interesting. I would use BASH for that. If you using MySQL:

# Run any SQL
mysql -uWhateverUserName -p the_db -e "SELECT * FROM users"

# Find files
find /whatever/path  -type f -name "*.py"
Enter fullscreen mode Exit fullscreen mode

If you want to find files using PHP


<?php

$files = glob('/any/path/*.py');
foreach($files as $f) {
  print $f . PHP_EOL;
}
Enter fullscreen mode Exit fullscreen mode

For Database access:

<?php

$pdo = new PDO('mysql:host=127.0.0.1;port=3306;dbname=mydb;charset=utf8', 'myuser', 'password');

$stmt = $pdo->prepare("SELECT * FROM users where id = ?");
$stmt->execute([1]);

# This is not efficient for large datasets, you should fetch in batches
$users = $stmt->fetchAll(PDO::FETCH_ASSOC);
Enter fullscreen mode Exit fullscreen mode
Collapse
 
efpage profile image
Eckehard

Thanks a lot. Usually I find a working solution. But I´m unsure if my solution is good.

What about safety, how to deal with passwords etc... So I would like to use some code written by professionals, that do a better job than me.

Thread Thread
 
kwnaidoo profile image
Kevin Naidoo

For passwords - most BASH utilities accept a "-p" or something similar option that prompts you for a password instead of your entering in the terminal. use "man command" to get the possible flags.

Environment variables can be used for storing passwords, then in your scripts - you reference the env variable instead of the actual password. Environment variables can be accessed by anyone on the machine so there's an element of risk here.

For maximum security, you would create a system user who cannot ssh, so you ssh via one user using a hardware key and then switch users. The passwords are then stored in that user's profile - so cannot be accessed from anywhere on the machine. But this might be overkill.

As for where to find professional code, look on github.com, lots of open-source projects - I would look for reputable projects e.g. Django, Laravel, Microsoft, etc... all depends on the specific code you need.

Collapse
 
kwnaidoo profile image
Kevin Naidoo

Great stuff! , as a big fan of PHP myself, this is a really good article. PHP 7+ is a whole new language, modern, and productive, with types and a ton of features but people still think of PHP from 10 years ago.

Collapse
 
mohitbansal321 profile image
Mohit Bansal

Thank you for this post
But as I see more jobs towards (Js, python)
please see as a fresher
if I learn about larval how can I see my future (asking only)

Collapse
 
tanzimibthesam profile image
Tanzim Ibthesam

If your area has more jobs on any tech stack go for that no problem. Laravel is great any tool is great if you can master the core language and database and underlying concepts beside it.

Collapse
 
mohitbansal321 profile image
Mohit Bansal

You are right but I need an opinion
I mean to say that if I learn larval (I have to learn it anyway)or master it
There could be jobs for larval developers (In startups)

Thread Thread
 
tanzimibthesam profile image
Tanzim Ibthesam

Startups !== Small IT Business. Just look forward to the jobs in startups its not possible to know which startup uses which tech stacks.
If you have to learn just go for it. Try to understand core php and put a lot of effort in Databases specially sql. I believe you should do well. But with Laravel there are lots of Freelancing and remote job opportunities if you are well skilled.Best of luck in whatever path you select.

Thread Thread
 
mohitbansal321 profile image
Mohit Bansal

yes I enhancing myself in SQL and PHP Can you share some good resources
how can I find growth-oriented jobs for this tech stack (less than one 1 year experience )

Collapse
 
mexikode profile image
MexiKode ⚙

PHP is great, just remember: libraries == Good, frameworks == Evil

Collapse
 
ryugenxd profile image
Ryugen 京

like this

Collapse
 
devshreeom profile image
OM JADHAV

The structure of PHP 🐘is worse like in java and c# we use split() but here u have to use explode()💥 still 70% web pages are using PHP🙂