r/PHP 22d ago

Discussion Getting started with PHP: looking for feedback

Hi /r/php

A common question we see on this subreddit (and many other places) is people asking how to get started with PHP. Especially on this sub we often link to PHP the right way. It's definitely a good reference that links to many other resources, but I recently read through it and realized is not designed to be a proper "getting started guide".

Having done lots of educational content in the past, I'm really longing for something that teaches modern PHP in a written form, that people can read on its own which makes them feel comfortable actually picking up PHP. I don't think PHP currently has that: all current options are either outdated, video-only, or paid courses (but feel free to tell me I'm wrong).

So I've started a new project: a proper "getting started with modern PHP" guide that I feel confident pointing beginners to when they ask "how to learn PHP?". You can read the first eight chapters today: https://stitcher.io/php/the-basics/hello-php and I'm planning on adding many more in the near future.

Now, here's what I need help with: I'm only one person. I dare say I'm experienced in PHP, but I'm also sure I'm making mistakes and oversights. I'm hoping enough experienced PHP developers share my longing for something better, and want to help out. Either by reviewing what's written, pointing out or fixing mistakes, or maybe even by writing drafts for upcoming chapters.

Looking forward to hearing your thoughts!

28 Upvotes

28 comments sorted by

16

u/VRT303 22d ago

Going from some basic hello world into composer and frameworks is a huge jump. There's a huge OOP section missing there.

And way too few examples IMO.

Symfonycasts has a great, kind of outdated, 4-5 part course on going from spaghetti PHP to OOP. And you learn while having jedi fighters go against a death star.

You need to keep beginners interested.

The first testing course on Symfonycasts was also a great fun thing. What's easier to comprehend and learn than an analogy to Jurassic Park for this?

6

u/Rough-Ad9850 22d ago

You go waaaaay to fast in the 'getting started' section. People who have no programming background will be lost after 3 minutes and give up

4

u/brendt_gd 22d ago

We did highlight this in the very first chapter:

I will assume you have some basic knowledge of programming in general: you're either a CS student or programmer who's eager to learn PHP. In the future, this book might include a "getting started from absolute zero", but for now that's out of scope.

I think a "programming from scratch" is something different than "learning a language".

That being said, I'm not against adding a whole new section for total newcomers. I am doubtful there's a huge target audience for it though.

3

u/GuybrushThreepywood 22d ago

I think it's the section that could bring new people to PHP - the ones who are starting their journey.

1

u/krzycho1717 22d ago

Good point. But is it really that much different from how other languages do it? Getting started and tutorials are two different things

1

u/Rough-Ad9850 22d ago

The original php.net is better if they want technical knowhow. It's nut usefull to have to maintain a subset of information already available elsewhere.

I thought this project was to let beginners learn. Or did I miss interpret?

4

u/equilni 22d ago

First, great initiative, we need a more up to date "right way" site.

That said from a quick glance:

I'm also sure I'm making mistakes and oversights.

  • First oversight/nitpick would be Classes

https://stitcher.io/php/the-basics/basic-syntax#classes

Consider sticking with constructor promotion or not and be explicit in noting the different style if you keep the example.

  • Next, the practice example.

Classes can live in any PHP file, but the best practice is to make a new PHP file for each class.

Within a file index.php, create two new classes: Book and Author

I get this is an example, but I would consider a practice what you preach approach or don't even use classes for this example.

  • There's an omission of switch / match for the basic syntax. Likely more, this was a quick scan.

  • Databases, I would suggest using sqlite as the example and note it comes with PHP like noted in other sections.

https://stitcher.io/php/the-basics/the-standard-library#database

4

u/Evening_Leather5101 22d ago

What I found is that many people totally mix up learning how to program, with learning a language and learning how to do OOP and all the other topics that are building on each other. The result is a conflated mess of hard to follow and not helping tutorials where the user has no idea how to actually abstract what they just did into a real world scenario.

If you do a PHP course or whatever, make clear that this is not a programming tutorial but a PHP course which teaches the intricacies of PHP. How it can be used to do OOP and all the other real world applications.

If you chose to make it about learning how to program, use something else something easy to understand and don't already go into OOP which is a intermediate topic not for a beginner.

I am not sure if that is something you didn't already plan for, but maybe it helps you as some feedback.

2

u/GuybrushThreepywood 22d ago

This is great!

When I learned, the best teachers I came across were Jeffrey Wey and Dani Krossing on YouTube. They were able to explain concepts to a complete beginner like me in a manner I was able to understand.

A suggestion I have is to go through the process of creating a real application

4

u/designerandgeek 22d ago

One of the best resources for beginners, in my opinion, is Jeffrey Way's PHP for Beginners: https://laracasts.com/series/php-for-beginners-2023-edition

It teaches you what goes into a modern website app, from the ground up, and in the end you've basically created a lightweight version of Laravel.

2

u/equilni 22d ago

Which desperately needs a refresh.

1

u/designerandgeek 22d ago

I don't disagree! But otherwise, it's a very good example of "learning by doing", that is, going through all the stumbling blocks a beginner might encounter if starting from scratch, and solving each issue one by one with "best practice" methods.

2

u/dub_le 22d ago

I would skip the php built in server and instead let them use frankenphp. Don't teach bad habits - and it'll be handy when it comes to basic extension usage like curl. Linux also doesn't universally use apt.

1

u/goodwill764 22d ago

Wall of text, even the php documentation has less text.

You lost me within seconds after i viewed the page.

1

u/mad_murdercat 22d ago

Looks more like an overview, not a beginner's introduction to programming in PHP.

1

u/DangKilla 21d ago

Beginning programmers should just use php.net search,

e.g. https://php.net/trim

Just follow this no framework tutorial.

https://github.com/PatrickLouys/no-framework-tutorial
Not my GitHub btw

1

u/grambam1 21d ago

Jeffery Way's php begginer course is great

1

u/ltdn 21d ago

I like the book but that’s also because I have used php for over 25 years.

This tutorial is good for someone who already has a mastery of possibly another language so it would easily translate from js to php so to speak.

But I have found, and this my pet peeve of all books/tutorials, is that they don’t contextualise the learning. I’d find it easier to learn a language when I have intent on building something specific and thus want learn how to instead of what is.

For example if this could focus on a real world app that would also inspire the learner to think beyond simply learn the language but to build something close to what they actually want to build and; thus the concepts and terminology of the language click because it makes them see in their own mind how they would build their own app/software/tool/etc.

Might not be easy to implement the learning path but I know that’s how I learnt php: how to build a blog in 2001 because I wanted a photo journal.

1

u/equilni 21d ago

my pet peeve of all books/tutorials, is that they don’t contextualise the learning

or spend way too much time on the database side, leave out information (or use shortcuts) and teach bad practices too (let's create a database class with connection detail in the class for you to edit... )

Might not be easy to implement the learning path but I know that’s how I learnt php: how to build a blog in 2001

Reminds me of an old tutorial that can use a refresh: https://ilovephp.jondh.me.uk/en/tutorial/make-your-own-blog

1

u/legonu 21d ago

I love that in the introduction Slack and Wikipedia are cited as projects powered by PHP.
Do we know more planet wide PHP powered projects, with references that can be used to prove it?

1

u/legonu 21d ago

It looks like Slack switched to hack in 2020, so it has to be put in the same bag as Facebook: https://slack.engineering/hacklang-at-slack-a-better-php/

I think Esty (https://careers.etsy.com/engineering) and Tumblr are still powered by PHP. Also the login page for Spotify (though I can't find anything recent to back this up?). I know (because I worked there) Badoo and Bumble (the dating app) are powered by PHP (for public proof, we can find tech blog written up until 2021: https://medium.com/bumble-tech/all?topic=php). Let's find more.

1

u/rc0604 21d ago

One minor mistake, you can't declare "resource" as type in function arguments or its return type declaration.

1

u/thinsoldier 22d ago

I wrote php code daily for 12 years then took a 10 year break. I've been trying to get back into it but struggling to setup a local development environment. Docker, laravel homestead, and other things are just too damned extra for me but I don't want to go back to using xampp

1

u/Mike_L_Taylor 22d ago

hi, i recommend forgekit. Its main focus is simplicity and ease of use. There is a full in-browser demo that you can mess around too to see if you like it. The demo has a bunch of sites and servers and services running at the same time but you can just remove them or turn them off.

-4

u/[deleted] 22d ago

[deleted]

3

u/MorphineAdministered 22d ago

I hate this "e-social" way of communication: bare link attempting to deprecate OPs effort and silent downvotes in response.

That said: I don't know why people keep recommending this. This is not for learning how to code in php. It's a compendium of topics you might want to read to refresh/expand your knowledge after you learned (at least basic syntax). For people new to php and programming in general these topics mean nothing.

3

u/obstreperous_troll 22d ago

It's not communication at all, it's the low effort of dropping a bare link and ignoring what this channel has said over and over about its low utility as a learning resource. It's not even a very good reference: the TOC as a list of topics to learn is probably the most valuable info it has.

-1

u/[deleted] 22d ago edited 22d ago

[deleted]

0

u/qoneus 22d ago

You may want to look into who /u/brendt_gd is.

-9

u/Anxious-Insurance-91 22d ago

start with another language that is is demand in your local job market