14
votes
Need recommendation for codecademy-like course for PHP
Hi there,
It looks like codecademy took down their PHP course, which stinks becuase I love, love, love how that site approaches teaching by doing. Any other free resources out there for a do-not-show approach for learning PHP?
Looking to get my feet wet so I'm a little less dangerous when tinkering with my WordPress templates.
Whatever you end up doing, make sure it's based on >= PHP 7.0. There have been some awesome new features/changes which make code cleaner and life easier!
Thanks. Anything I do will be amateurish and hacky most likely :) my big need right now to is to modify an existing form to do some data validation using http post to confirm input in another sites database. Definitely function over form on this one lol
The inclusion of the null coalescing operator is such a small thing, but easily my favorite because it cuts down on the verbosity and makes code much more readable.
Yes! Also return types on functions, they added void in 7.2. Keeps things structured and clean.
If FreeCodeCamp has a PHP training course, that might be the way to go for you.
Thanks for the solid recommendation. I just now looked and didn't see anything, but that site looks pretty sweet so thanks for sharing :)
You're welcome. It's a really helpful site and community.
If you do end up learning Python instead or alongside of PHP, these may help:
Adding on to this:
Project Python, "a free interactive book that will teach you to code in Python, using graphics, animations, and games"
I would recommend not to spend time learning PHP. It is an old technology on its way out, your time is probably better spent elsewhere (e.g. ruby on rails, django)
well that is a little bit on personal opinion, but what ruby, django etc has better than php? i never done something "big" with PHP but it seems like an ok lang to learn
It's not really a personal opinion so much as an observation of facts.
PHP is an objectively bad language. I don't think it's "on the way out" but it is certainly "in decline" from it's place of prominence as the #1 language to learn if you want to do web development. You can see this by just looking at the differences in job availability on LinkedIn, or similar. PHP used to be the top requested thing, now it's not. Python, Ruby and Javascript are the go-to languages, and other languages are coming up fast behind them.
As to why PHP is an objectively bad language... this is 6 years old but still worth a read. It's a goodly part of why senior devs tend to hate PHP; there's just better tools for just about everything.
BTW the analogy in the article with the weird tools like the double-claw hammer is flawed in my opinion. A proper analogy would be that you have regular tools as well as weird tools at your disposal. It's up to the "carpenter" to know which tool to choose. A good carpenter knows better than to use the double-claw hammer to hammer a nail just because it happened to be at arm's reach. There is a way to do things properly in PHP and they are encouraged by the community.
I think you're misunderstanding the analogy. There's no use for a double claw hammer.
It's certainly possible to build good things with PHP. I've done so - many others have done so. Just because it's possible to not fall into the pitfalls of PHP, that doesn't mean that it's okay that there are pitfalls.
Sure there are tools at your disposal which should never be used, mostly for legacy reasons, but isn't that true of other languages as well? I fail to see how that makes the language bad. I've yet to meet a PHP dev that does crazy stuff that's used as examples of "why PHP is bad".
I have a few questions, and I intend them all positively.
Did you read the entirety of the article? The thesis of the page I linked can be stated like as, "A good programming language should be predictable, consistent, concise, reliable, and debuggable. PHP has issues with all of these." I recommend reading the article - it gives a lot of very specific examples of the problems inherent in PHP and why it's a bad language.
Have you tried other languages? JavaScript doesn't count! Branching out of my PHP comfort zone into other languages was intrinsic in my understanding that what I had been doing was not as good for me as it could have been.
How long have you been doing this? What's the biggest project you've worked on? Did you use a framework for it? Have you done non-framework stuff? Do you have a mentor?
The answer to each of these has an effect on how you feel about PHP. I think it's important to note that people aren't saying, "You can't build cool stuff with PHP" or "you can't be a good coder and use PHP" or anything like that, but they are (almost universally) saying that PHP itself isn't good. Some phenomenal software uses PHP, and to great effect, and PHP has many strengths. Being a good language just isn't one of them.
I have read the article. The article is from 2012 and is quite outdated tbh. It provides examples that mostly make me go "ok but why would you do that". For example the ternary thing - it has never been a problem for me because I use a switch statement or an associative array - both of which I find more readable and clean.
I have tried other languages - I actually started with Pascal, then wrote stuff in C, C++ and Java. I also tried Python, but I never found the time to learn the non-C syntax well enough to feel comfortable with the language. I'm a CS major so I had to learn a bunch of languages and best practices. Right now I'm mostly a team leader and not so much a coder anymore.
I've been a web developer for over 8 years and I've worked on projects that used frameworks (Zend and Symfony). I have done non-framework stuff for very small assignments, but for those a framework would have been overkill anyway. As for the biggest project - how do you measure that? In terms of LOC the biggest project I've built from scratch currently has over 200k lines of PHP code (plus a bunch of HTML, JS as you would expect). I've worked on "bigger" projects but I always took care of just some subset of the whole codebase.
I used to have a mentor when I was a beginner.
People are saying both "You can't build cool stuff with PHP" and (especially) "you can't be a good coder and use PHP" - I've heard that far too many times. I understand that's not your point of view and I appreciate that.
I do not consider myself a PHP fan. I don't love PHP. I just don't understand the sheer level of hate it gets. It's like Nickelback of the programming world. The real issues I experience when writing code are related to management, specification, crazy external APIs and random infrastructure issues. PHP has never really been a problem for me or any of the PHP devs I know. Meanwhile Java and C# devs I know complain about the same stuff I do. Maybe the language is not really such a big problem?
EDIT: I'd just like to point out that this is the most civilized discussion regarding PHP I've experienced online.
I think the point is that you really shouldn't be able to do things that make you say that. There are certainly weird constructions and things I don't like about each of the languages that I used (let's not start talking about Javascript for example), but there are a lot of weird and bad things that one can do with PHP.
I actually meant a lot of these as variants of "how much experience do you have" and I think you answered that very well. I'm not trying to get in a measuring contest at all, but I think it's only fair to answer the same, just so we're on the same page. I've been a developer for 20 years, worked in frameworks and without. I've worked on some large code bases. I've written a bunch of different stuff, but my preferred language is Python (though Rust is making a play for that spot of my heart right now). I had a mentor.
Sorry, I meant that people in this thread weren't saying that. I've definitely heard that sentiment many times, and it's just... so obviously stupid and indefensible. Facebook, Wikipedia, Yahoo, Flickr, Tumblr, Sourceforge... a lot of big, interesting, influential sites are built using PHP. And obviously a great developer goes where the money is!
I think that one of the things to remember is that PHP was the default for a lot of time, so when beginners were doing something, they were often in PHP doing those things. Part of this means that a lot of the bad stuff that's out there is PHP because a lot of the stuff out there is PHP. So people see a lot of bad PHP and they make an equivalence - I see a lot of bad PHP, so PHP is bad. I think that a lot of people feel like PHP sucks for that reason, and not for all the well thought out reasons in the article I cited, which kind of jives with how people make decisions about things (ie - we often make a decision quickly, and then we justify it with reasons, instead of having reasons first, and reaching decisions based on them).
These are the universal problems. Good luck with them. They're in Python, Go, Rust, Ruby, Haskell, and Lisp too.
I feel like we're both pretty reasonable people, so that's likely the reason. I know that sometimes my writing gets a bit aggressive or agitated or know-it-all-y, so I've been trying to work on that, so I'm glad that we've mostly avoided that.
I remember back in university when I brought my OS to its knees when I was working on some basic algorithm assignment and I exhausted the computer's RAM by mistake. That was C++. Languages allow you to do stupid destructive things, but if you know what you're doing, you don't do those things. I do recognize the fact that C++ allows you to do destructive things because it's powerful and PHP just has some bad parts :) - but those aren't really used in the real world. PHP has changed substantially in the last 5 or so years and it's really not difficult to write robust maintainable applications in the language.
Many things have changed since that article, the most important one is PHP 7 which addresses several of the things the author complained about, like the old mysql functions and lack of strict typing. Here's a good overview of the changes.
Thank you. The anti-PHP meme is an old one but the language itself has come a long way. Ultimately one language can’t be ranked “objectively” better or worse than another, it comes down to taste and the strength of the ecosystem. The PHP dev community is alive and well.
It’s true that PHP empowers novices to embrace some bad habits. But it’s also more than up to the task of handling large-scale, mission-critical systems and there are tons of well-architected applications that use it. I think people who dismiss it out of hand are being flippant, and probably forming an opinion around outdated information.
Could you elaborate on what you mean by taking care of "almost everything"?
Most languages don't include graceful handling of network requests in their standard library. Because of this, the above will generally hold true. This "write every check on your own" or, more generally, "repetitive code" is what we refer to as "boilerplate code". The existence of boilerplate code in your code base is a pretty strong indicator that you've made a bad design decision somewhere, and particularly in the case where you're dealing with network requests, it's usually an indicator that you're in desperate need of a framework.
Some languages include additional libraries that you can use within the standard installation. From what it looks like, I would assume you're using ASP.NET in C#. Take note that ASP.NET is part of the .NET Framework. Thus, C# provides this simplicity as part of an included framework package. C# itself isn't some magical language, it just has development labor dedicated toward maintaining an optional package that you can use. In that sense it's really not much different from PHP, as PHP has development labor (external rather than internal, of course) dedicated toward maintaining frameworks like Laravel. Without that framework package, you would be dealing with just as much boilerplate as a framework-less PHP project.
In short: whether it's the language maintainers, a third party, or even ourselves who develop them, frameworks are king. If you're not using a framework for web development, then you've loaded up a gun and pointed it directly at your foot, and it's only a matter of time before you find yourself missing some toes.
C# can be used without .NET, actually. It's used heavily in Unity without it, for example.
As for the "best practices" argument, I've heard this a lot about a lot of different languages. The problem is that the language itself shouldn't try to enforce best practices, but instead provide the sort of programming paradigm it wants. PHP is incredibly powerful when used correctly, owing largely to its flexibility. If someone has a tendency to introduce boilerplate, then they'll manage to do that at the business logic level even with the network boilerplate out of the way.
I would also argue that dealing with boilerplate early on is a good thing. You get to learn what it looks like and the headaches involved, and you better understand how the network requests function at a lower level instead of blindly trusting a magic black box. Then when you move onto using a framework, you're intimately familiar with the inner workings and can write code more effectively.
Thank you for the comprehensive example. I think you might have a very skewed view of how PHP development happens. When you use an industry standard framework like Symfony or Laravel, you can easily do all of the above in about as many lines of code. Throw in some extra annotations and you also get autogenerated documentation with a nice GUI.
Yeah PHP without a framework is rough, but I think that's mainly because you're kind of expected to use a framework if you're working on a webapp. Not using a framework feels like not using an IDE. Technically you can code in notepad, but why would you do that?
Also on top of that I take PSR standards for granted. If you don't know what they are, you haven't really learned PHP. But that's just my opinion.
I've worked with it over the last few years and it's still a huge technology used all over the web. Also PHP 7.2 was released recently :)
DJANGO and Python are awesome. iconfinder.com is built on them and their project has come a long way.
You can build more sophisticated things with it and DJANGO has all this time saving functionality. Read two scoops of django.
These comments are kind really annoy me. Had this been StackOverflow I'd have recommended deletion this a not an answer. OP isn't asking if they should or shouldn't learn PHP, they were asking if you had any resources that were of reasonable quality of learning the language. It shouldn't matter what your personal opinion of the language is, if you don't have the resources then don't comment, no need to shit on the thread because because you don't like the language.
It just serves to derail the thread and turn it into a religious war about languages and ignore the original request of the individual
I agree, I was pretty tempted to remove a huge chunk of this thread (and if I had looked at it earlier I probably would have). The post specifically says that they're working with WordPress templates, "learn a different language instead" isn't an option and is completely irrelevant.
There's a general guideline about commenting I've seen before (I thought it was on HN, but I can't see it in their guidelines), that says that you shouldn't post comments if they're basically just a generic reaction to the subject, almost like a bot that responds automatically based on keywords. "Post mentions PHP -> tell them that PHP is bad and they should use something else".
When we get the comment tags back, I think "offtopic" or even "noise" tags would be appropriate for situations like this.
Regarding bashing PHP in particular, these comments always seem lazily dismissive as well. No language is built to handle web requests gracefully out of the box. That's why we build frameworks and use those instead of reinventing the wheel. And if your IDE is so out of date that you have to memorize function parameter order instead of tab auto-completing, then you probably need to update your toolset anyway.
Honestly, there seems to be a lot of elitism surrounding C and C-like languages in general. It's kind of frustrating to see this kind of circlejerk on Tildes. It's part of what put me off with Reddit's programming communities.
Agreed, this goes back to my topic about tech tribalism. I really hope we can set a higher standard here.
@Deimos I look forward to the return of tags, I certainly hope that OT/noise tags also help to push down conversation below actual content, it's rather gross that this thread is only barely edged out an actual response and has effectively killed any new top level comments due to its size.
Slightly off-topic, but I actually replied to that very topic! :)
I understand but I'm learning it because that's what all WordPress templates use and that's what my site currently runs on. So while your opinion is nice, it's not terribly helpful.
BTW COBOL programmers are still in demand...
https://www.cio.com/article/3050836/developer/why-its-time-to-learn-cobol.html
Yeah, you're probably right. I didn't mean to come off dismissive, I honestly didn't know if you're just looking to start developing in php or just fiddle around with it
Dang it, you linked my favourite shitting-on-PHP article before me, and now I look like a copycat!
It's important to stipulate that PHP 7 does mitigate some of the issues that the Fractal of bad design article brings up, and there are some great things being built in PHP, but for the most part, it's just... bad.
I don't know. I've got a big repository of old, obsolete languages in my head, and while some of them are useful tools to teach certain programming concepts, most of them represent old concepts that are no longer used. When switching languages I often find people write the new language in the same "style" of the old language (in my circles, it's people writing C++-like python code), which is very confusing and unwieldy. But you're right, that is my personal opinion
I think one thing PHP has going for it (for better or worse) is that it's a C-like syntax. Many people learn C/C++/Java in school and then jumping to a completely different syntax like that of Pyton or Ruby can feel tedious. If you know Java, it's very easy to learn PHP because you mostly already know the syntax.
But why are you recommending languages that are even older than PHP and even more on their way out? Django's ORM doesn't even use prepared statements by default. Typescript, Elixir, and kotlin are much better suggestions if you want something that's actually better.
Because I didn't go by language age, went what's popular and useful these days. I don't know what makes you think python is on its way out. But yes, there are certainly newer languages
Wordpress is the most popular CMS in the world, with 59.9% market share (compared to other CMSs). OP expressed a desire to tinker with WordPress templates. I don't know if PHP is shit or not, but it seems useful for this purpose.
I'd say this too. PHP was big in early to mid 2000s. If you want to learn it, build something simple and use the php website to reference functions. It's how I learned. Well, I took a part Wordpres and other cms things back around 2003 when I learned. I modded phpBB forums as a trade for web hosting.
I'd look at Python.
Mostly free website, I learned C# there. ict.social.
Some advanced articles are payed, but you don't really need them, the important things and basics are for free. They teach you how to write the code, you won't find much theory there. It's in form of short articles. If you find an article that is behind paywall, skip it, it's probably just an exercise that you don't need. Exercises and advanced articles (like making an eshop) are payed, rest is for free.
Around 8 years ago, when I had to use PHP, I learned it with Head First PHP & MySQL. I love the Head First series, it has a very different approach to learning that really helps me keep focus and learn quickly. The problem is that the book is now about 10 years old, so it will likely be outdated. I haven't used PHP in a really, really long time, so I'm not sure of any good up-to-date resources, this book is the best I can provide.