Jeśli jesteś właścicielem tej strony, możesz wyłączyć reklamę poniżej zmieniając pakiet na PRO lub VIP w panelu naszego hostingu już od 4zł!

Archive for Marzec, 2017

Site News: Blast from the Past – One Year Ago in PHP (03.30.2017)

Site News: Blast from the Past – One Year Ago in PHP (03.30.2017)

Here’s what was popular in the PHP community one year ago today:

Source: http://www.phpdeveloper.org/news/25048

<!–
var d = new Date();
r = escape(d.getTime()*Math.random());
document.writeln('’);
//–>

Site News: Blast from the Past – One Year Ago in PHP (03.30.2017)

Site News: Blast from the Past – One Year Ago in PHP (03.30.2017)

Here’s what was popular in the PHP community one year ago today:

Source: http://www.phpdeveloper.org/news/25048

<!–
var d = new Date();
r = escape(d.getTime()*Math.random());
document.writeln('’);
//–>

Medium.com: A Package for Snapshot Testing in PHPUnit

Medium.com: A Package for Snapshot Testing in PHPUnit

In this post on Medium.com Sebastian De Deyne shares a package from Spatie that makes it simpler to perform "snapshot testing" in your PHP applications.

The gist of snapshot testing is asserting that a set of data hasn’t changed compared to a previous version, which is a snapshot of the data, to prevent regressions. The difference between a classic assertEquals and an assertMatchesSnapshot is that you don’t write the expectation yourself when snapshot testing. When a snapshot assertion happens for the first time, it creates a snapshot file with the actual output, and marks the test as incomplete. Every subsequent run will compare the output with the existing snapshot file to check for regressions.

Snapshot testing is most useful larger datasets that can change over time, like serializing an object for an XML export or a JSON API endpoint.

Our package, which exposes a trait to add snapshot testing capabilities to your tests, can be installed via composer and is available on GitHub.

He starts with a basic example, checking to verify that a string hasn’t changed between test runs. The first run creates the snapshot (marking the test as incomplete) and then following runs verify – one passing (no change) and one failing (changing of the return string). He also includes examples of tests on objects, mentions where the snapshot files are stored and how to add drivers for additional snapshot storage types.

Source: http://www.phpdeveloper.org/news/25047

<!–
var d = new Date();
r = escape(d.getTime()*Math.random());
document.writeln('’);
//–>

Medium.com: A Package for Snapshot Testing in PHPUnit

Medium.com: A Package for Snapshot Testing in PHPUnit

In this post on Medium.com Sebastian De Deyne shares a package from Spatie that makes it simpler to perform "snapshot testing" in your PHP applications.

The gist of snapshot testing is asserting that a set of data hasn’t changed compared to a previous version, which is a snapshot of the data, to prevent regressions. The difference between a classic assertEquals and an assertMatchesSnapshot is that you don’t write the expectation yourself when snapshot testing. When a snapshot assertion happens for the first time, it creates a snapshot file with the actual output, and marks the test as incomplete. Every subsequent run will compare the output with the existing snapshot file to check for regressions.

Snapshot testing is most useful larger datasets that can change over time, like serializing an object for an XML export or a JSON API endpoint.

Our package, which exposes a trait to add snapshot testing capabilities to your tests, can be installed via composer and is available on GitHub.

He starts with a basic example, checking to verify that a string hasn’t changed between test runs. The first run creates the snapshot (marking the test as incomplete) and then following runs verify – one passing (no change) and one failing (changing of the return string). He also includes examples of tests on objects, mentions where the snapshot files are stored and how to add drivers for additional snapshot storage types.

Source: http://www.phpdeveloper.org/news/25047

<!–
var d = new Date();
r = escape(d.getTime()*Math.random());
document.writeln('’);
//–>

SitePoint PHP Blog: Game Development with ReactJS and PHP: How Compatible Are They?

SitePoint PHP Blog: Game Development with ReactJS and PHP: How Compatible Are They?

The SitePoint PHP blog has a new tutorial posted from Christopher Pitt (known for his "interesting" uses of PHP) covering the combination of ReactJS and PHP in game development. He wants to answer the question of how compatible they are and provide an example to help illustrate.

I started thinking about this the moment I decided to try and build a game using PHP and ReactJS. The trouble is that I knew nothing about the dynamics of multiplayer games, or how to think about and implement player-based economies.

I wasn’t even sure that I knew enough about ReactJS to justify using it. [...] I once watched a talk, by dead_lugosi, where she described building a medieval game in PHP. Margaret inspired me, and that talk was one of the things that lead to me writing a book about JS game development. I became determined to write about my experience. Perhaps others could learn from my mistakes in this case, too.

He hops right in to the code from there, starting with the setup of the backend functionality making use of Aerys for the HTTP/WebSocket handling. He creates a few basic routes then moves on to the frontend using Laravel Mix to pull in the dependencies he needs and perform the steps needed to build things out. He then goes through the process of creating the application frontend and connecting the WebSocket requests to a "GameSocket" endpoint. He finishes up the post with updates the Javascript to add in functionality to send a message to all users connected to the WebSocket.

Source: http://www.phpdeveloper.org/news/25046

<!–
var d = new Date();
r = escape(d.getTime()*Math.random());
document.writeln('’);
//–>

SitePoint PHP Blog: Game Development with ReactJS and PHP: How Compatible Are They?

SitePoint PHP Blog: Game Development with ReactJS and PHP: How Compatible Are They?

The SitePoint PHP blog has a new tutorial posted from Christopher Pitt (known for his "interesting" uses of PHP) covering the combination of ReactJS and PHP in game development. He wants to answer the question of how compatible they are and provide an example to help illustrate.

I started thinking about this the moment I decided to try and build a game using PHP and ReactJS. The trouble is that I knew nothing about the dynamics of multiplayer games, or how to think about and implement player-based economies.

I wasn’t even sure that I knew enough about ReactJS to justify using it. [...] I once watched a talk, by dead_lugosi, where she described building a medieval game in PHP. Margaret inspired me, and that talk was one of the things that lead to me writing a book about JS game development. I became determined to write about my experience. Perhaps others could learn from my mistakes in this case, too.

He hops right in to the code from there, starting with the setup of the backend functionality making use of Aerys for the HTTP/WebSocket handling. He creates a few basic routes then moves on to the frontend using Laravel Mix to pull in the dependencies he needs and perform the steps needed to build things out. He then goes through the process of creating the application frontend and connecting the WebSocket requests to a "GameSocket" endpoint. He finishes up the post with updates the Javascript to add in functionality to send a message to all users connected to the WebSocket.

Source: http://www.phpdeveloper.org/news/25046

<!–
var d = new Date();
r = escape(d.getTime()*Math.random());
document.writeln('’);
//–>

SitePoint PHP Blog: Game Development with ReactJS and PHP: How Compatible Are They?

SitePoint PHP Blog: Game Development with ReactJS and PHP: How Compatible Are They?

The SitePoint PHP blog has a new tutorial posted from Christopher Pitt (known for his "interesting" uses of PHP) covering the combination of ReactJS and PHP in game development. He wants to answer the question of how compatible they are and provide an example to help illustrate.

I started thinking about this the moment I decided to try and build a game using PHP and ReactJS. The trouble is that I knew nothing about the dynamics of multiplayer games, or how to think about and implement player-based economies.

I wasn’t even sure that I knew enough about ReactJS to justify using it. [...] I once watched a talk, by dead_lugosi, where she described building a medieval game in PHP. Margaret inspired me, and that talk was one of the things that lead to me writing a book about JS game development. I became determined to write about my experience. Perhaps others could learn from my mistakes in this case, too.

He hops right in to the code from there, starting with the setup of the backend functionality making use of Aerys for the HTTP/WebSocket handling. He creates a few basic routes then moves on to the frontend using Laravel Mix to pull in the dependencies he needs and perform the steps needed to build things out. He then goes through the process of creating the application frontend and connecting the WebSocket requests to a "GameSocket" endpoint. He finishes up the post with updates the Javascript to add in functionality to send a message to all users connected to the WebSocket.

Source: http://www.phpdeveloper.org/news/25046

<!–
var d = new Date();
r = escape(d.getTime()*Math.random());
document.writeln('’);
//–>

Zend Framework Blog: Handling OPTIONS and HEAD Requests with Expressive

Zend Framework Blog: Handling OPTIONS and HEAD Requests with Expressive

The Zend Framework blog has continued its series of posts focusing on the use of the Zend Expressive framework with a new tutorial covering handling OPTIONS and HEAD requests in an Expressive-based API.

In v1 releases of Expressive, if you did not define routes that included the OPTIONS or HEAD HTTP request methods, routing would result in 404 Not Found statuses, even if a specified route matched the given URI. RFC 7231, however, states that both of these request methods SHOULD work for a given resource URI, so long as it exists on the server. This left users in a bit of a bind.

[...] In the case of a HEAD request, the specification indicates that the resulting response should be identical to that of a GET request to the same URI, only with no body content. This would mean having the same response headers. In the case of an OPTIONS request, typically you would respond with a 200 OK response status, and at least an Allow header indicating what HTTP request methods the resource allows. Sounds like these could be automated, doesn’t it? In Expressive 2, we did!

The tutorial then shows you the code you’ll need to add to your Expressive v2 application for handling each kind of request. It involves some custom middleware using the route handling on the HEAD request type for one and the other for OPTIONS. The HEAD requests return an empty response while the OPTIONS requests return the data from a manually defined array (no automatic generation from routes or anything).

Source: http://www.phpdeveloper.org/news/25045

<!–
var d = new Date();
r = escape(d.getTime()*Math.random());
document.writeln('’);
//–>

/Dev/Hell Podcast: Episode 89: Selling Out Never Felt So Good

/Dev/Hell Podcast: Episode 89: Selling Out Never Felt So Good

The /Dev/Hell podcast, hosted by PHP community members Chris Hartjes and Ed Finkler, has posted their latest episode – Episode #89: Selling Out.

Chris and Ed decided to push themselves out of their comfort zone and talked to Laravel community superstar Matt Stauffer. We talked about Matt’s experience writing a book for a major publish (with an animal on the cover and everything), asked the question “does consistency in code matter for OSS projects” and Chris sadly muted his mic while Matt and Ed discussed the Analogue NT Mini gaming console.

You can listen to this latest episode either using the in-page audio player or by downloading the mp3 directly. If you enjoy the show, be sure to subscribe to their feed and follow them on Twitter to get the latest information about new episodes as they’re released.

Source: http://www.phpdeveloper.org/news/25044

<!–
var d = new Date();
r = escape(d.getTime()*Math.random());
document.writeln('’);
//–>

Benjamin Eberlei: Explicit Global State with Context Objects

Benjamin Eberlei: Explicit Global State with Context Objects

In a post to his site Benjamin Eberlei looks at global state in PHP using something called "context objects" and how they can be used as an alternative to true global state.

Global State is considered bad for maintainability of software. Side effects on global state can cause a very nasty class of bugs. Context objects are one flavour of global state. For example, I remember that Symfony1 had a particularly nasty context object that was a global singleton containing references to very many services of the framework.

As with every concept in programming, there are no absolute truths though and there are many use-cases where context objects make sense. This blog posts tries to explain my reasons for using context objects.

He starts by getting everyone on the same page by defining a context – the "circumstances in which something can be fully understood". He then moves into the world of context objects, talking about how they encapsulate the information other objects need to execute. They’re essentially "container" objects that allow for more control that something like the normal PHP superglobals. From there he helps you define what kind of context objects you might need in your application and provides a real-world example from his own experience at Tideways.

Source: http://www.phpdeveloper.org/news/25034

<!–
var d = new Date();
r = escape(d.getTime()*Math.random());
document.writeln('’);
//–>