8 ms·
PHP Apprentice – An online, open-source book for learning PHP
- noir_lord 8y agoLooks like good material and the formatting is nice so kudos.
- xfour 8y agoVery well done, there’s a lot to help a novice PHP developer. I feel like the next chapters I’d love to see would take those concepts and apply them to building something. Everything so far unless I missed it is focused on the backend but it’s important to show that it’s also possible to use it as a front end and what the modern approaches to doing that are.
- restoreddev 8y agoI plan to add a new section for learning how to use the concepts to build a basic website. I wanted to start with backend foundation first.
- acomjean 8y agoThats a good point. PHP is a general language, but used almost exclusively for web development and most websites now use a framework (symfony/laravel......) etc. I'm learning symfony framework after my micro framework of choice lost its support (Silex..). The symfony documents are ok, but I wouldn't want to give them to someone starting out. (though looking again, they seem better..) https://symfony.com/doc/current/page_creation.html https://symfony.com/doc/current/page_creation.html Someone showed me the free video cast howto build a basic symfony site. I though it was pretty good. Like many of these, the basic tutorials are free, but its a subscription site. https://symfonycasts.com/tracks/symfony https://symfonycasts.com/tracks/symfony
- tangue 8y agoNice job and well written. A nice addition would be how to use pdo. I'm appalled by the number of ressources I see online which are using the old mysql api.
- settler4 8y agoThis is a very good resource for PDO: https://phpdelusions.net/pdo https://phpdelusions.net/pdo
- meritt 8y ago> I'm appalled by the number of ressources I see online which are using the old mysql api Recently authored articles? We have an internet filled with 20 years of PHP tutorials, and unfortunately for beginners there's not an easy way to evaluate if something utilizes modern best practices or is an Experts Exchange post from 2001.
- prophesi 8y agoYep, the plethora of out-of-date resources is what I'd place as the main issue with PHP today. I usually steer people to use the Laravel framework since it makes it difficult to write bad/dangerous code.
- mattigames 8y agoI find strange you can't down-vote a link on Google, it should exist and Google should take it into account specially for technical links (less so for opinions articles or anything political)
- jordigh 8y agoEverything is political. I wouldn't want people to downvote Mercurial links into oblivion. Anyway, Google links are pretty much already ordered by popularity.
- mattigames 8y agoThat's the problem, in technical links popularity (as in number of visits) is not linked to correctness, that's one of the reasons StackOverflow is so useful, because the top-voted answer is like 99% of the times the most correct (useful) one.
- erusev 8y agoLooks great! Perhaps, making it possible to turn pages with the arrow keys on the keyboard would make it a bit easier to navigate.
- Kiro 8y agoYeah, that was my first reaction as well! With the chapters being this short (which itself is great) it would be really nice to be able to use the arrow keys.
- Vanderson 8y agoNot sure if the dev will see this, but it would be nice if it was a little easier to get to the table of contents as well. My suggested code change. (quick a dirty example) .menu { margin-bottom: 1.5em; position: sticky; top: 0; z-index: 1000; background: #fff; padding: 10px; }
- restoreddev 8y agoNoted! That would be an easy addition.
- restoreddev 8y agoFYI, just implemented this on the site. Thanks for the suggestion!
- smougel 8y agoGood job ! Please add something about namespaces.
- settler4 8y agoAnd composer!
- restoreddev 8y agoIt’s on the roadmap!
- DoctorPenguin 8y agoWhy not teach it better? https://glot.io/snippets/f8g0wlar0d https://glot.io/snippets/f8g0wlar0d No wonder PHP developers have a bad reputation.
- mweibel 8y agoI downvoted you because your comment doesn't help anybody and is offensive. Why do you think your example is better?
- DoctorPenguin 8y agoBecause the examples given in this "book" teach a bad coding style and explain nothing in detail. If a trainee only used this to prepare for the final exams and I was to ask a more in depth question he would propably fail. Example: "Why do you use double quotes everywhere?" Most probable answer: "Because I can use variables and the backslash-n thingies everywhere and its more convinient than using single quotes." Example: "Why do you use '. "\n";' instead of the PHP_EOL constant?" Most probable answer: "What is PHP_EOL?"; Example: "Why aren't you using namespaces anywhere?" Most probable answer: "What are namespaces?" Altough this might be a german perspective but I would not hire someone that presents me this kind of code. And for anyone saying "But this is only one book to learn the basics?" why not learn it the right way from the start?
- keb_ 8y agoNot sure I follow. What are your criticisms, specifically?
- deleted 8y ago[deleted]
- txsoftwaredev 8y agoNice job. I would suggest all PHP devs spend some time with https://phptherightway.com https://phptherightway.com. Your resource looks to be a great starting point.
- lillesvin 8y agoNot disagreeing but I usually recommend that people read http://www.phpthewrongway.com/ http://www.phpthewrongway.com/ afterwards to get a more pragmatic viewpoint.
- Aeolun 8y agoTo be honest, it reads more as someone being salty they don’t understand the point of frameworks.
- lillesvin 8y agoI think you skimmed the article too quick then because there are plenty of good and well supported arguments in it.
- Aeolun 8y agoI think I read mostly to the end before giving up on it. There’s a lot of arguments, I just don’t think they’re particularly good. Don’t misunderstand me, there is a point there, but it’s buried under a load of text.
- Kaos-Industries 8y agoI regularly use bash and I have learnt HTML, CSS and JavaScript in the past. If I had to use only one of these resources - OP's site or PHP the Right Way - which would you recommend I use? To put it some other ways - does OP's site adequately cover best practices? Is PHP the Right Way targeted aimed at fully-fledged programmers who want to pick up PHP? Thank you in advance, it's much appreciated.
- xemoka 8y agoNice little reference for anyone who already knows how to program, but might not know PHP. For anyone else, this isn't really going to help. There seems to be no explanation of _why_ you would want to do anything here or even how it relates to a goal. Who is your audience?
- reacweb 8y agoIMHO, I think the audience is me. I can program (perl, java, c++). I know that php is easy but that there are many traps. I need a book to be able to develop quickly with sane practices. The official documentation contains too much old crust.
- xemoka 8y agoToo much old crust, but as other commenters around indicate, this isn't really solving that either: it doesn't talk about best practices or even highlight where the sharp edges are (EOLs and Namespaces are mentioned elsewhere).
- dvtrn 8y agoThis was my same takeaway thumbing through. I think I'll take the weekend to grok PHP a bit better. Thanks for publishing this op!
- chrismeller 8y agoI love PHP, it was my first “real” programming language, and I’m glad there are still people trying to make it easier to adopt. Having skimmed through several of these chapters, though, I just feel like it’s too similar to the official PHP docs, even down to the TOC. Wouldn’t it have been better for everyone to put this effort into improving the docs, rather than developing yet another book in a silo that likely won’t have the longevity we’d like?
- restoreddev 8y agoI started with foundational concepts which will overlap some with the official docs. The advantage of my site is I wanted it to be more readable, since the official docs can be hard to navigate. In the future, I want to cover topics like Composer and Slim which would not be appropriate for PHP.net.
- chrismeller 8y agoThat’s cool and does give the comprehensive approach some credence, but still feels like duplicated effort and the potential for outdated content (on both sides). FWIW, I don’t think giving a more readable aspect to the official docs would be bad. It’s already got way more of that feel than it did in PHP 4, when it had more of an MSDN auto-generated parameter documentation feel. With the clear sections and code snippets I think both could be achieved with little extra effort.
- thanatropism 8y agoImagine this kind of reception for any other content. Someone spends a year into composing a new symphony and the reviews go "I love live music but wouldn't it have been better if the composer would have re-orchestrated a familiar classic rather than developing a whole new score that won't be performed as often as we'd like?"
- jabberthemutt 8y agoThat analogy makes no sense.
- tombert 8y agoI haven't used PHP in around 6 years (running PHP 4 I belive); has the language improved ? My biggest complaint was that the API was incredibly inconsistent, but that seemed like it could be improved in later versions if they weren't afraid of breaking backwards compatibility.
- ok_coo 8y agoIt has improved a lot in that time and I find it decent to work with now that there's decent dependency management with Composer and a good Rails-like framework in Laravel.
- kminehart 8y agoThere have been a number of improvements in the latest PHP versions, especially in terms of performance. There's still artifacts of past PHP versions that are there, though, which makes it far less nice to use than something more modern.
- duiker101 8y agoI have been using PHP for a new job after not using it since PHP 4 too but I was also a very immature dev back then. I quite like it. It's not perfect and it still lacks some things but it's very easy to put something together. I think that my biggest problem is actually that it's too easy, which makes some people write code that it's a bit too sloppy and hard to understand, creating a possibly huge technical dept.
- smhg 8y agoIt was likely PHP 5. The last PHP 4 release is more than 10 years old [1]. Later versions of PHP 5 were worlds apart from version 4. [1] http://php.net/supported-versions.php http://php.net/supported-versions.php
- tombert 8y agoI'm pretty sure it was 4, the company I was working for was...let's just say "slow to update", which is partly why I left.
- 8y ago
- Geee 8y agoThe null coalescing operator ?? is not well explained. It returns the first operand but if it's not set or null, will return the second operand, i.e: $name = $_GET['name'] ?? $_POST['name'] ?? "unknown"; In the arrays section, I'd also introduce the $array[] shorthand for array_push(), i.e: $array[] = $new_element;
- restoreddev 8y agoThanks for reading! This is still a young project with room for improvement and new sections. I’m already planning some content for building web pages, database access and package management with Composer. I wrote an announcement post over on dev.to if you want to read more about how the site was built: https://dev.to/restoreddev/announcing-php-apprentice-coc https://dev.to/restoreddev/announcing-php-apprentice-coc
- deleted 8y ago[deleted]
- akhk8726 8y agoWell written and easy to read- hugely valuable resource! Can't wait to see more.
- Anthony-G 8y agoThe content is great. I like how you start off teaching the language by showing how to execute simple programs from the command line (I learned that you don’t need the `-f` option to execute a file). I’ve come across far too many PHP introductions that confuse the new learner by attempting to get them to set up a web server (usually Apache) and then all the strings have to be wrapped in HTML markup when printed. There’s a lot to be said for keeping it simple for teaching the essentials of a language. The site is cleanly and beautifully formatted and I love how lightweight it is: HTML files, a CSS file, a JS file and an image. It’s such a refreshing change from the thousands of visually cluttered sites that make hundreds of resource requests (most of them third-party) and whose content is not visible without allowing third-party JavaScript. When I completely disabled JavaScript on this site, all I noticed were non-essentials such as Solarized syntax highlighting and the Table of Contents; I could still navigate through the site using the Previous and Next links (and of course, the browser’s Back button). Kudos!
- wolco 8y agoI can't understand sites without a fallback so many are turning javascript off.
- restoreddev 8y agoThanks! I really made it a goal to keep the site lightweight and simple.
- Hacker_Support 8y agoHire a hacker to help protect your children from cyber predators. Our professional hackers can find the source and help close the case on any investigation. Hire a Hacker! Everyone loses a password at some point. We help crack/recover passwords from computers, mobile & wireless devices, E-mail accounts, FaceBook and more! Hire hacker! Has your Facebook, Twitter or Google+ account been attacked by a hacker? Do you need to get back into a social media account? A Professional Hacker Can Help! Any email is hackable and we can get in and recover your passwords. Hire a professional hacker to recover your personal data. Hire an Email hacker now! Our professional hackers can encrypt any data and help protect sensitive information from any other hacker who might try to hack your systems or yoir devices. Hire a hacker now! No matter what your hacking need, we can get it done in a professional and timely manner. You can send us a mail to hacktech@hackermail.com With round the clock support you can reach one of our Ethical Hackers or our staff quickly and get your project started.