Subscribe: PHPDeveloper.org
http://www.phpdeveloper.org/phpdev.rdf
Added By: Feedage Forager Feedage Grade B rated
Language: English
Tags:
blog  code  database  domain  dry principle  helpers  laravel  mocking  model  news laravel  news  oracle  part  router  site  time  vue 
Rate this Feed
Rate this feedRate this feedRate this feedRate this feedRate this feed
Rate this feed 1 starRate this feed 2 starRate this feed 3 starRate this feed 4 starRate this feed 5 star

Comments (0)

Feed Details and Statistics Feed Statistics
Preview: PHPDeveloper.org

PHPDeveloper.org



Up-to-the Minute PHP News, views and community



Published: Sun, 25 Feb 2018 16:28:39 -0600

 



Web-Techno.net: The DRY principle misunderstood

Fri, 23 Feb 2018 11:55:36 -0600

On the Web-Techno.net site there's a new tutorial posted that talks about the DRY principle in development (Don't Repeat Yourself) and why you might be misunderstanding the intent.

I know what you are thinking: "Again a boring article on DRY? Don't we have enough already?". You might be right. However I see too many developers (junior or senior) applying DRY like they are doing some witch hunting. Totally randomly or everywhere they can. So apparently we never have enough DRY principle articles on Internet.

A little reminder for those in the back who don't follow: the DRY principle means "Don't Repeat Yourself" and was first introduced in the The Pragmatic Programmer. The principle itself was known and applied before this book came to life. However the Pragmatic Programmer defined it precisely and put a name on it.

He starts by defining the original intent of the principle: not repeating knowledge (not necessarily repeating code). He gives an example of a e-commerce site and the logic around "shipments". If there's logic around these shipments happening in multiple places in the application, that can lead to maintenance issues down the line. He suggests creating a single instance of the knowledge about shipment handling rather than just reducing code duplication. He gives an example of a product instance and code duplication happening in some of the data validation. After showing a possible solution for this particular issue he gets into some issues that come from over-DRYing your code including useless abstractions and premature optimization.




php[architect]: Education Station: Shifting and Masking with a Side of Crypto

Fri, 23 Feb 2018 11:34:45 -0600

The php[architect] site has posted an article published in their February 2018 issue by Edward Barnard as a part of his "Education Station" column. The article covers bit shifting and how it relates to cryptography in PHP.

The basics can be tricky. This month we take a careful walk-through of a few lines of cryptographic code in PHP. This leads us through the difference between ones’ complement and two’s complement representation. We achieve weirdness by combining logical AND with integer addition.

He starts with a bit of a history lesson going back to mainframes and keypunching followed by a look at the logical and bitwise operators. He then takes some of these basics and applies them to the world of cryptography and provides some example code and a constant-time encoding algorithm. This leads to a discussion about ones' compliment, signed zero, two's compliment and "packing".




CloudWays Blog: Create A Laravel Vue Single Page App In Under An Hour

Fri, 23 Feb 2018 10:15:51 -0600

The CloudWays blog has a new tutorial posted that walks you through the process of getting a Laravel+Vue single page application running in less than an hour. The instructions for the server portion cover the use of CloudWays' service but they could be applied to any number of other hosting providers.

Laravel has become the most popular choice for developing PHP projects. One important reason for this popularity is the built in support for Vue, a very fast growing JavaScript library for developing impressive front-ends.

This combination results is fast, secure and very impressive applications that need minimum time to go from ideation to final code review. The support for Vue means that Laravel developers could use Vue components easily within their apps without wasting time in writing integrations for the components. To demonstrate the support, I decided to create a single page application in Laravel with a Vue powered frontend.

They start off with a list of prerequisites (software to have installed) and then move on to setting up the database and creating a "tasks" migration. The tutorial then covers building out the authentication handling (via artisan) and the creation of the "task" model and controller. With all of that in place it starts in on the backend functionality to read, create, update and delete the tasks. Next it moves to the frontend showing how to create the Vue components required and integrating the Javascript into the view to link it to the backend for managing the tasks.




Christopher Jones: Installing XAMPP for PHP and Oracle Database

Fri, 23 Feb 2018 09:47:03 -0600

On the Oracle and PHP blog today Christopher Jones has posted a tutorial showing you how to install Oracle support in PHP on a XAMPP setup. Oracle support requires the installation of the OCI8 PHP extension.

This post shows how to install XAMPP on Windows to run PHP applications that connect to a remote Oracle Database.

XAMPP is an open source package that contains Apache, PHP and many PHP 'extensions'. One of these extension is PHP OCI8 which connects to Oracle Database.

The post walks you through each of the steps required to get the combination up and running:

  • Downloading and installing XAMPP
  • Ensuring thread safety is enabled
  • Editing the php.ini to enable the OCI8 module
  • Installing the Oracle Instant Client

The post also includes some example code you can use to ensure the connection is up and working, selecting information from the default database.







Nicolas Grekas: Making Symfony router lightning fast - 2/2

Thu, 22 Feb 2018 12:54:30 -0600

Nicolas Grekas has posted the second part of his look at the work that was done to increase the performance on the router in version 4 of the Symfony framework. In part one he covered some of the basic changes made to the router for faster matching. In this latest article he covers some of the "tweaks" made on top of this work to help improve things even more.

In Making Symfony’s Router 77.7x faster - 1/2, we learned how to build a faster URL matcher, using hash-map lookups for static routes, and combined regular expressions for routes with placeholders, while preserving all the advanced features of the Symfony router. However, more work was needed for some real world apps, as at least one of them experienced a slow down. Let’s see how fixing this provided us with (one of) the fastest PHP routers out there.

He then starts working through some of the newer changes to help "reclaim" some of the performance loss in certain situations. He talks about same-prefix route ordering, subpatterns and placeholders to change how the combined regular expressions perform the matching on the incoming URL. The result is an even more performant routing system that's 77 times faster than what they started with.




Matthias Noback: Mocking at architectural boundaries: persistence and time

Thu, 22 Feb 2018 11:07:35 -0600

In a new post to his site Matthias Noback takes a look at unit testing your code and how it can be "dangerous" if you use mocking/doubles in the wrong way (not effective testing). Instead, he makes the recommendation to mock at architectural boundaries, specifically looking at mocking persistence and time handling.

More and more I've come to realize that I've been mocking less and less. The thing is, creating test doubles is a very dangerous activity.

[...] For example, by creating a test double for the EntityManager, we're assuming that it will work well with any objects we'll pass to it. If you've ever debugged an issue with an EntityManager, you know that this is a bad assumption. Anything may go wrong: a mistake in the mapping, missing configuration for cascading persist/delete behavior, an issue with the database credentials, availability of the database server, network connectivity, a missing or invalid database schema, etc.

He then gets into the concepts behind mocking across the "architecturally significant boundaries" and what kind of functionality this involves. He then gets into the two different examples sharing some of the basic concepts and test examples for evaluating persistence and time handling. He finishes up with a look at some of the potential consequences ("outcomes" is really a better word) of refactoring your tests and code to follow these ideas.




Pehapkari.cz: Domain-Driven Design - Implementation

Thu, 22 Feb 2018 10:15:35 -0600

The Pehapkari.cz blog has continued their series covering domain-driven design with their latest post. In this new article they focus on the implementation of the concepts they've been covering starting with the domain model.

It is great to model something and now we have reached the point where we turn the model into the code. We will implement the model, no persistence, no input, only the most important part - the domain model. The implementation will be supported by tests and we will see how easy it is to test domain objects. We will also discuss the connection to the ubiquitous language and model and practical aspect of object encapsulation.

The tutorial then starts in covering the domain model structure and includes a few things to to think about during the implementation. It talks about reading values from the object and links to the full code on GitHub (rather than fill up the post with code). The post finishes by covering testing of the model, the idea of test-driven development and how it fits in with domain-driven design.




Laravel News: 5 Laravel Helpers to Make Your Life Easier

Thu, 22 Feb 2018 09:45:32 -0600

On the Laravel News site they've posted a new article with a listing of five useful helpers that come standard as a part of the Laravel framework.

There are a ton of helper methods in Laravel that make development more efficient. If you work with the framework, I encourage you to see what helpers you can introduce in your day-to-day work. In this blog post, I’d like to point out a few of my favorites.

The list in the post includes helpers for locating information in an array, pluralizing strings, throwing exceptions based on conditions and accessing object property values. For each item on the list there's a brief explanation and some sample code showing it in action (and what the result ends up being). The post finishes up by linking you over to the helpers page of the Laravel manual for more information and other handy functions to help reduce your own development time.