Follow Slashdot stories on Twitter

 



Forgot your password?
typodupeerror
×

Submission + - Modern PHP: New Features and Good Practices

Michael Ross writes: Robert, here is the book review meta-data: author: Josh Lockhart pages: 268 publisher: O'Reilly Media rating: 8/10 reviewer: Michael Ross ISBN: 978-1491905012 summary: Solid advice on some state-of-the-art PHP tools and techniques.

In recent years, JavaScript has enjoyed a dramatic renaissance as it has been transformed from a browser scripting tool primarily used for special effects and form validation on web pages, to a substantial client-side programming language. Similarly, on the server side, after years as the target of criticism, the PHP computer programming language is seeing a revival, partly due to the addition of new capabilities, such as namespaces, traits, generators, closures, and components, among other improvements. PHP enthusiasts and detractors alike can learn more about these changes from the book Modern PHP: New Features and Good Practices, authored by Josh Lockhart.

Programmers familiar with the language and its community may recognize the author's name, because he is the creator of PHP The Right Way, a website which he describes as "an easy-to-read, quick reference for PHP popular coding standards, links to authoritative tutorials around the Web and what the contributors consider to be best practices at the present time," in 21 different languages.

Yet rest assured that the book under review is not merely a dead-tree version of the website. Instead, the book covers the more recent advancements within the language, while the website covers best practices and standards. This should be borne in mind, otherwise the reader may be baffled by the absence from the book of certain topics on the website essential to the language, such as SPL, PEAR, and PHPDoc. Moreover, of the topics shared between the book and the website, the information is generally organized quite differently, with more example code in the book.

This title was published on 1 March 2015, under the ISBN 978-1491905012, by O'Reilly Media, who kindly provided me with a review copy. Its material is presented in 268 pages, organized into 13 chapters (The New PHP; Features; Standards; Components; Good Practices; Posting; Provisioning; Tuning; Deployment; Testing; Profiling; HHVM and Hack; Community), which are grouped into three parts (Language Features; Good Practices; Deployment, Testing, and Tuning) — as well as two appendices (Installing PHP; Local Development Environments) and an index. The publisher's page does not offer much of interest. However, all of the example code is available from the book's GitHub repository. There are differences between the GitHub code and what is printed in the book, e.g., a baffling require 'vendor/autoload.php'; in the first example code file. The author claims that the reader does not need to know PHP, but at least "a basic understanding of [] fundamental programming concepts" (page xiv). However, anyone without at least intermediate skills and experience with PHP could conceivably struggle with these more advanced subjects.

The first chapter is only a brief overview of the history of PHP, its current state, and some possible future changes to the language's engine. The real content starts in the second chapter, in which the author gives the reader a fast-paced introduction to his seven favorite major new features in PHP: namespaces, class interfaces, traits, generators, closures, Zend OPcache, and the built-in HTTP server. In some regards, the coverage is a bit too fast-paced, as some topics and questions likely in the reader's mind are not addressed — for instance, namespace case-sensitivity and techniques for ensuring that a chosen namespace is globally unique (page 9). For each topic, its purpose and advantages are explained, and sometimes illustrated with code examples, although none are extensive.

The second part of the book opens with a chapter on some of the new standards in the PHP ecosystem that are intended to move the common development process from a reliance upon one isolated framework, with an idiosyncratic coding style, to distributed components that can interoperate through the use of interfaces, industry-wide coding standards, and the use of autoloaders for finding and loading classes, interfaces, and traits at runtime. Components are covered in more detail in the subsequent chapter, as is Composer, for installing components and managing dependencies. The fifth chapter is a lengthy but information-packed exposition of numerous best practices regarding input data sanitization, password handling, dates and times, and safe database queries, among other topics. Some of the advice can be found in other PHP books and online, but all of this is neatly explained, updated with the newer PHP versions, and worthwhile as a refresher.

Deployment, testing, and tuning are the broad subject areas of the third and final part of the book. The author discusses the options for hosting your PHP applications, as well as provisioning any self-managed web server and tuning a server for optimal performance. All of the instructions assume you are using Linux and nginx, and thus would be of less value to those using Windows or Apache, for instance. The material on application deployment is relatively brief, and focuses on use of the Capistrano tool. Testing is often neglected in real-world projects, but certainly not in this book, as the author explains unit and functional testing, illustrated through the use of PHPUnit. This is followed by information on how to use a development or production profiler to analyze the performance of your application, with detailed coverage of Xdebug and XHProf, among other tools. The next two chapters dive into topics related to the (possible) future of PHP — specifically, Facebook's HHVM PHP interpreter and their Hack derivative language. The final chapter briefly discusses the PHP community. The two appendices explain how to install PHP on Linux or OS X for commandline use, and how to set up a local development environment. The author mentions a free edition of Zend Server, but the vendor page mentions no such pricing.

Despite its technical subject matter, this book is not a difficult read. The author's writing style is usually light and friendly, especially in the preface. In a few places, the phrasing is a bit too terse, which might prove momentarily confusing to some readers, e.g., "Function and constant aliases work the same as [those of] classes" (page 11). The text has some errata (aside from the two, as of this writing, already reported): "curl" (pages 15, 220, and 222; should read "cURL"), "a an argument" (page 33), "Prepared statement [to] fetch" (pages 99 and 100), "with [the] php://filter strategy" (page 110), "2 Gb" (page 129; should read "2 GB"), "the the" (page 154), "path to a the code" (page 176), and "Wordpress" (page 190; should read "WordPress").

One weakness with the book is that for several of the topics — including some critical ones — there is not enough detailed information provided that would allow one to begin immediately applying that technique or resource to one's own coding, but instead just enough information to whet one's appetite to learn more (presumably from another book or a website). Secondly, some of the narrative — particularly near the end of the book, when discussing various tools — would be of less value to anyone not developing analytics environment. Beware that some of the tools require numerous dependencies. For instance, do you have Composer, Git, MongoDB, and its PHP extension installed? If not, then you won't be using XHGUI. Also, some of the installation and configuration steps are quite lengthy, with no details provided for troubleshooting issues that might arise. Lastly, despite the promise that any reader with only basic programming knowledge will be able to fully understand the book, such a reader would likely find much of its contents mystifying without further preparation from other sources.

Nonetheless, the book has much to offer, despite its slender size. Numerous resources are recommended — most if not all apparently vetted by the author, who clearly has considerable experience in this arena. Some valuable techniques are presented, such as those instances in the text where the author shows how to use iteration on large data sets to minimize memory usage. In addition, the example code demonstrates that the author has made the effort to produce quality code that can serve as a model to others. Modern PHP does a fine job overall of explaining and advocating the newer capabilities of PHP that would attract developers to choose the language for building state-of-the-art websites and web applications.

Michael Ross is a freelance web developer and writer.

Submission + - FTC's internal memo on Google teaches companies a terrible lesson (washingtonpost.com)

schwit1 writes: FTC staffers spent enormous time pouring through Google's business practices and documents as well as interviewing executives and rivals. They came to the conclusion that Google was acting in anti-competitive ways, such as restricting advertisers' from working with rival search engines. But commissioners balked at the prospect of a lengthy and protracted legal fight.

For a big company, that process may have been enlightening. Agency staffers might find evidence of anti-competitive behavior. But that doesn't mean the firm will face the music in the end.

Previous attempts to go after big companies — such as the Justice Department's long-running antitrust case against Microsoft in the 1990s — loomed large in regulators’ minds at the time of the Google probe, according to a former official who worked at the agency then.

“Even if we were in the right and could win," said the former official, "it could take a lot of resources away from other enforcement.”

Comment Re:Bad move by Konami (Score 1) 42

It is a graphics term, the Depth Buffer Test, is commonly abbreviated Z-Test by us graphics guys.

On the PS2's GS (Graphics Synthesizer) the z test can be set to a few of the normal 8 values:

NEVER, ALWAYS, LESS, LEQUAL, EQUAL, GREATER, GEQUAL, NOTEQUAL

One of the tests, LESS_THEN_EQUAL, IIRC, was completely broken. The reality was that you had to reverse the test and work-around it. Not a HUGE problem, but still, a sign of SCEI making custom hardware and not fully testing it. (i.e. The memory cards on the PS1 was extremely flakey.)

Fore more details see the OpenGL man pages on depth buffer testing: https://www.opengl.org/documen...

Submission + - A software project full of 'male anatomy' jokes is going crazy right now (businessinsider.com)

An anonymous reader writes: There's no question that the tech world is an overwhelmingly male place. There's legit concern that tech is run-amok with "brogrammers" that make women programmers feel unwelcome. On the other hand, people just want to laugh.

It's at that intersection that programmer Randy Hunt, aka "letsgetrandy" posted a "project" earlier this week to software hosting site GitHub called "DICSS."The project, which is actual free and open source software, is surrounded by geeky jokes about the male anatomy. And it's gone nuts, so to speak, becoming the most trending project on Github, and the subject of a lot of chatter on Twitter. And, Hunt tells us, the folks at Github are scratching their heads wondering what they should do about it.

Some people love DICSS (and, we have to admit, some of the jokes did make us snicker) ... and some people are, understandably, offended.
The offended people point out that this is exactly the sort of thing that makes tech unwelcoming to women, and not just because of the original project, but because of some of the comments (posted as "commits") that might take the joke too far. (And, we have to admit, the tech world really doesn't need another thing that encourages sexism. A lot of male programmers are just as sick of that as women are.)

Whats Slashdot's opinion? Harmless fun? Sexism run rampant?

Comment Re:Bad move by Konami (Score 1) 42

Clarifications / Fix typos:

Sight, not site
* was a beautiful sight

Games, not developers:
* On Xbox games were typically CPU bound, while on PS3 games were typically GPU bound.

SCE (Sony Computer Entertainment), not Sony
* SCE forgot what business they were in!? They were NOT a hardware manufacturer, but an entertainment company. It cost them 4 years of being in the red

Sony makes the most from insurance. Sony Computer Entertainment (SCE) owns

* SCEA (America)
* SCEE (Europe)
* SCEJ (Japan)

Comment Re:Bad move by Konami (Score 4, Interesting) 42

Having shipped a few PS2 games, and helped numerous PS3 devs, the situation is a little more complicated then that.

The PS2 had *blazing* fast VRAM bltblt copies. Yes, the cpus (EE, SPU, IOP, VU0, VU1) were a complete bitch to write for, but it was a beautiful site to behind when everything was working.

While the PS2 had a completely broken Z-Test (who the hell QA'd this??), it was ahead of its time. It predicted multi-core architecture that (game) devs had to embrace sooner or later. The Xbox with its unified memory definitely made things WAY easier then the complicated PS2.

The PS3 with its 6 SPU's of only 128KB each (!) forced developers to break the game up into "small jobs". It highlighted the problems of C++ OOP -- that it doesn't scale, and that you NEED to use DOD (Data Orientated Design) in order to achieve high performance. So while the PS2 and PS3 were "batshit insane" it had unintended benefit -- help move developers to embrace the "multi-core DOD" future.

On Xbox developers were typically CPU bound, while on PS3 developers were typically GPU bound.

The problem with the success of PS2 and failure of the PS3 was that Sony forgot what business they were in!? They were NOT a hardware manufacturer, but an entertainment company. It cost them 4 years of being in the red with the PS3 to remember this fact.

Sony moving to x86 for the PS4 allowed them to use "commodity" parts & pricing. Make things _easy_ for the developer and you'll get more/better games, or at least that was their justification.

So while I agree that yes x86 game devs tend to be lazy compared to console devs, the x86 guys had a valid point:

* Why is the hardware SO complicated?

The battle between fast & rigid and slow & flexible is never an easy one to answer.

Submission + - Microsoft Reveals Windows 10 Hardware Requirements And Upgrade Paths

An anonymous reader writes: A lot of news is coming out of Microsoft’s Windows Hardware Engineering Community (WinHEC) event in Shenzen today. Following details of Windows 10’s worldwide launch this summer, the upgrade paths and hardware requirements for the company’s latest and greatest operating system have been revealed in two sets of PowerPoint slides. Before you can upgrade to Windows 10, you’ll need to know if your device can handle the new OS. You should also be aware of your available options for the upgrade process (as always, wiping everything and installing Windows 10 from scratch is your safest bet).

Comment Re:Utility vs. freedom (Score 4, Insightful) 114

Great. Then you don't mind if I take a hit out on your life? I mean, its just a contract, the fact its to kill someone doesn't outweigh my liberty to enter into it, does it?

Congratulations, you've just said the stupidest thing I've ever read on the internet. That includes "Where does babby come from".

Comment Re:Learning trumps instincts (Score 1) 77

> A computer has more than enough time to evaluate the problem, cause, and solution, and has no need to "guess" at the solution.

Just to play Devil's Advocate. That is an underlying assumption there: That the computer has

1) enough
2) valid

data to make to a solution that makes sense in that context?

The problem with rules is that there is always exceptions. i.e. Sometimes accelerating will avoid the accident!

Is the program smart enough to widen the search space and consider alternative solutions?

The rest of your post is interesting.

Comment Re:Personal freedom trumps software freedom (Score 2) 214

Ah, so we should toss the baby out with the bathwater simply because you dislike _his_ work flow. Riiight.

/sarcasm I guess no one else got the memo that we ALL should follow _your_ divine workflow and use _only_ the software that you "bless" as being "valid". Who die and made you king again?

Philosophy doesn't depend on technology. It is about how it can/should be used.

It would behoove you to study history.

"The easiest form of parochialism to fall into is to assume that we are smarter than the past generations, that our thinking is necessarily more sophisticated. This may be true in science and technology, but not necessarily so in wisdom."

Macaulay on dangers of Copyright in 1841

Comment Re:Personal freedom trumps software freedom (Score 2) 214

> in most countries you aren't allowed to [do] absolutely anything you please with it. So what? Its just a phone.

And where does it end?

Printers and their DRM ink cartridges?

Game Consoles?

TVs?

Computers?

Cars?

It is _already_ illegal to _inspect_ some of the things you "own" due to the greedy and immoral DMCA.

When you can't even charge the _battery_ this is _already_ going TOO FAR.

* https://www.eff.org/deeplinks/...

Comment Re:Convenience (Score 1) 214

Straw man argument.

1. No one is forcing you to choose _that_ GPL software.
2. Closed source (Non-GPL) software is ALSO forcing _their_ license upon you. I am FORCED _not_ to be allowed to distribute it, etc.

Your argument is completely and totally bogus.

Slashdot Top Deals

God made the integers; all else is the work of Man. -- Kronecker

Working...