Subscribe: Planet PHP
http://www.planet-php.org/rss/
Added By: Feedage Forager Feedage Grade B rated
Language: English
Tags:
based  compare  cpu  entity  fpm  governor  lighthouse  max  performance  static  symfony  time  tool  tools  validate  validation 
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: Planet PHP

Planet PHP



People blogging about PHP



 



Faculty - Chris Shiflett

Tue, 12 Dec 2017 07:00:00 +0000

(image)

Today, I am proud to introduce Faculty. We design, engineer, and build really great websites and apps.

I love the web, and I feel fortunate to have been working on the web since its inception. From writing CGIs in C and laying out pages with tables, to CSS Grid and serverless computing, it has always been fulfilling to bring new ideas to life and share them with others.

I also love working with smart, friendly people who obsess over the details as much as I do, and I’m grateful to those who are continuing this journey with me. We’re an experienced team, and we enjoy using our experience to unlock the potential of our clients.

Faculty is the culmination of everything I’ve learned about technology, design, and business. If you think we can help you, please do let us know, and thanks in advance for your support.




Symfony 4: Performance out of the Box - Fabien Potencier

Mon, 11 Dec 2017 00:00:00 +0000

Performance is an interesting and sensitive topic. Suffice to say that most projects should not care too much; modern PHP frameworks are fast enough for most use cases and projects. And PHP 7 performance improvements help a lot as well. But people like to compare frameworks, and I guess performance is one way to do so.

What about Symfony 4? During its development cycle, we did some nice performance optimizations: mainly to improve the router and container speed. But several non-related changes in Symfony 4 also help with performance... Your mileage may vary depending on your specific project of course.

Synthetic benchmarks that were made to back pull requests that claimed to improve performance do not always convert to gain on real-world projects. Now that Symfony 4 is out, it's time to test a full project. An "Hello World!" application benchmark is a good start as it helps understand the base performance of a framework. It helps understand the overhead added on top of PHP by your framework of choice. We spent so much time doing optimizations that I wanted to compare the out-of-the-box performance of a default Symfony Standard Edition project (based on Symfony 3) with the performance of a Symfony 4 project.

Benchmarking is a science and takes a lot of time. Luckily enough, and while I was procrastinating, someone did the work for me. The http://www.phpbenchmarks.com/en website has a great benchmark protocol and a great UI that let you browser and compare results easily.

According to those benchmarks, an "hello world" page on Symfony 4.0 is almost twice as fast as the same code using Symfony 3.4. You read that right. On PHP 7.2, Symfony 4.0 is twice as fast compared to Symfony 3.4.

There is also a benchmark for a more complex REST API application. Symfony 4 is again still much faster than 3.4.

Visit http://www.phpbenchmarks.com/en to get more numbers. Among other things, you will learn the following:

  • Symfony on PHP 7.2 makes your code quite a bit faster than 7.1;

  • Symfony 2.3 is the second fastest Symfony release since 2.0

  • Symfony 3.4 is the slowest release since 2.0 (deprecated features are probably one of the reasons);

  • Symfony 4.0 is almost three times faster as Laravel 5.5.

I would love to get some numbers for your application. Share them if you upgraded recently.

Enjoy using Symfony 4.0, the fastest Symfony ever released!

(image)



Whatsapp Chat from CLI Using Puppeteer - Sarfraz Ahmed

Sun, 10 Dec 2017 11:06:00 +0000

GoogleChrome puppeteer is interesting project to create browser automation tools, testing tools or web scrapping. I was wondering to use it for something useful and an idea popped in about creating CLI application that can be used to send and receive messages on Whatsapp. So I went on to creating Whatspup, a name based on both Whatsapp and puppeteer.

Features

  • Send and receive messages
  • Read Receipts
  • Switch between users to chat with
  • Popup notifications for new chat messages
  • Privacy settings for popup notifications
  • One-time authentication, no need to scan QR code again and again
  • Windowless/headless (hidden) mode
  • Colorful chat messages

Screenshot

(image)


Head over to Whatspup repository and start using it :)

(image)



Avoid Dependency Injection - Paul M. Jones

Tue, 05 Dec 2017 13:00:15 +0000

At least, avoid it when building DDD Aggregates:

Dependency injection of a Repository or a Domain Service into an Aggregate should generally be viewed as harmful. The motivation may be to look up a dependent object instance from inside the Aggregate. The dependent object could be another Aggregate, or a number of them. … Preferably, dependent objects are looked up before an Aggregate command method is invoked, and passed into it.

… Take great care not to add unnecessary overhead that could be easily avoided by using other design principles, such as looking up dependencies before an Aggregate command method is invoked, and passing them into it.

This is only meant to warn against injecting Repositories and Domain Services into Aggregate instances. Of course, dependency injection is still quite suitable for many other design situations. For example, it could be quite useful to inject Repository and Domain Service references into Application Services.

— “Implementing Domain Driven Design”, Vaughn Vernon, p 387.


On a related note, regarding where Entity validation logic goes, we have this …

Validation is a separate concern and should be the responsibility of a validation class, not a domain object.

— ibid., p 208

… and this …

Embedding validation logic inside an Entity give it too many responsibilities. It already has the responsibility to address domain behavior as it maintains its state.

— ibid., p 212

… but then we see this:

How do clients ensure that Entity validation occurs? And where does validation processing begin? One way places a validate() method on all Entities that require validation. … Any Entity can safely have its validate() method invoked. …

However, should Entities actually validate themselves? Having its own validate() method doesn’t mean the Entity itself performs validation. Yet, it does allow the Entity to determine what validates it, relieving clients from that concern:

public class Warble extends Entity {
    ...
    @Override
    public void Validate(ValidationNotificationHandler aHandler) {
        (new WarbleValidator(this, aHandler)).validate();
    }
}

… The Entity needs to know nothing about how it is validated, only that it can be validated. The separate Validator subclass also allows the validation process to change at a diferent pace from the Entity and enables complex validations to be thoroughly tested.

— ibid., p 214-215

It seems like a small step after that to inject a fully-constructed validation object into the Entity at construction time, and have the validate() method call that, instead of creating a new validation object inside the Entity.




Interview with Davey Shafik - Voices of the ElePHPant

Tue, 05 Dec 2017 12:30:29 +0000

(image)

Show Notes

The post Interview with Davey Shafik appeared first on Voices of the ElePHPant.

(image)



PHP 7.2.0 Released - PHP: Hypertext Preprocessor

Thu, 30 Nov 2017 00:00:00 +0000

The PHP development team announces the immediate availability of PHP 7.2.0. This release marks the second feature update to the PHP 7 series.PHP 7.2.0 comes with numerous improvements and new features such asConvert numeric keys in object/array castsCounting of non-countable objectsObject typehintHashContext as ObjectArgon2 in password hashImprove TLS constants to sane valuesMcrypt extension removedNew sodium extensionFor source downloads of PHP 7.2.0 please visit our downloads page Windows binaries can be found on the PHP for Windows site. The list of changes is recorded in the ChangeLog.The migration guide is available in the PHP Manual. Please consult it for the detailed list of new features and backward incompatible changes.Many thanks to all the contributors and supporters!



PHP-FPM tuning: Using ‘pm static’ for Max Performance - SitePoint PHP

Wed, 29 Nov 2017 17:00:11 +0000

Let's take a very quick look at how best to set up PHP-FPM for high throughput, low latency, and a more stable use of CPU and memory. By default, most setups have PHP-FPM’s PM (process manager) string set to dynamic and there’s also the common advice to use ondemand if you suffer from available memory issues. However, let's compare the two management options based on php.net’s documentation and also compare my favorite for high traffic setup --- static pm: pm = dynamic: the number of child processes is set dynamically based on the following directives: pm.max_children, pm.start_servers, pm.min_spare_servers, pm.max_spare_servers. pm = ondemand: the processes spawn on demand when requested, as opposed to dynamic, where pm.start_servers are started when the service is started. pm = static: the number of child processes is fixed by pm.max_children. See the full list of global php-fpm.conf directives for further details. PHP-FPM Process Manager (PM) Similarities to CPUFreq Governor Now, this may seem a bit off topic, but I hope to tie it back into our PHP-FPM tuning topic. Okay, we’ve all had slow CPU issues at some point, whether it be a laptop, VM or dedicated server. Remember CPU frequency scaling? (CPUFreq governor.) These settings, available on both *nix and Windows, can improve the performance and system responsiveness by changing the CPU governor setting from ondemand to performance. This time, let's compare the descriptions and look for similarities: Governor = ondemand: scales CPU frequency dynamically according to current load. Jumps to the highest frequency and then scales down as the idle time increases. Governor = conservative: scales the frequency dynamically according to current load. Scales the frequency more gradually than ondemand. Governor = performance: always run the CPU at the maximum frequency. See the full list of CPUFreq governor options for further details. Notice the similarities? I wanted to use this comparison first, with the aim of finding the best way to write an article which recommends using pm static for PHP-FPM as your first choice. With CPU governor, the performance setting is a pretty safe performance boost because it’s almost entirely dependent on your server CPU’s limit. The only other factors would be things such as heat, battery life (laptop) and other side effects of clocking your CPU frequency to 100% permanently. Once set to performance, it is indeed the fastest setting for your CPU. For example read about the ‘force_turbo’ setting on Raspberry Pi, which forces your RPi board to use the performance governor where performance improvement is more noticeable due to the low CPU clock speeds. Using ‘pm static’ to Achieve Your Server’s Max Performance The PHP-FPM pm static setting depends heavily on how much free memory your server has. Basically, if you are suffering from low server memory, then pm ondemand or dynamic may be better options. On the other hand, if you have the memory available, you can avoid much of the PHP process manager (PM) overhead by setting pm static to the max capacity of your server. In other words, when you do the math, pm.static should be set to the max amount of PHP-FPM processes that can run without creating memory availability or cache pressure issues. Also, not so high as to overwhelm CPU(s) and have a pile of pending PHP-FPM operations. In the screenshot above, this server has pm = static and pm.max_children = 100 which uses a max of around 10GB of the 32GB installed. Take note of the self explanatory highlighted columns. During that screenshot there were about 200 ‘active users’ (past 60 seconds) in Google Analytics. At that level, about 70% of PHP-FPM children are still idle. This means PHP-FPM is always set to the max capacity of your server’s resources regardless of current traffic. Idle processes stay online, waiting for traffic spikes and respon[...]



23 Development Tools for Boosting Website Performance - SitePoint PHP

Tue, 28 Nov 2017 17:00:44 +0000

When dealing with performance, it's hard to remember all the tools that might help you out during development. For that purpose, we've compiled a list of 23 performance tools for your reference. Some you'll have heard of, others probably not. Some have been covered in detail in our performance month, others are yet to be covered future articles; but all are very useful and should be part of your arsenal. Client-side Performance Tools 1. Test your Mobile Speed with Google Google’s Test My Site is an online tool offered by Google and powered by the popular website performance tool WebPageTest.org. You can either visualize your report on site or have it emailed to you via your email address. The tool gives you your website loading time (or Speed Index) calculated using a Chrome browser on a Moto G4 device within a 3G network. It also gives you the estimated percentage of visitors lost due to loading time. Among other things it also: compares your site speed with the top-performing sites in your industry gives you top fixes that can help you speed up your website loading time. 2. SiteSpeed.io SiteSpeed.io is an open-source tool --- or a set of tools --- that can help you measure your website performance and improve it. Image source: sitespeed.io Coach: gives you performance advice and fixes for your website based on best practices. Browsertime: collects metrics and HAR files from your browser. Chrome-HAR: helps you compare HAR files. PageXray: extracts different metrics (from HAR files) such as size, number of requests, and so on. You can install these tool(s) using npm: npm install sitespeed.io -g sitespeed.io --help Or Docker: docker run --shm-size=1g --rm -v "$(pwd)":/sitespeed.io sitespeedio/sitespeed.io https://www.sitespeed.io/ --video --speedIndex 3. Lighthouse by Google Lighthouse is an open-source tool for running audits to improve web page quality. It's integrated into Chrome's DevTools and can be also installed as a Chrome extension or CLI-based tool. It's an indispensable tool for measuring, debugging and improving the performance of modern, client-side apps (particularity PWAs). You can find the extension from the Chrome Web Store. Or you can install Lighthouse, from npm, on your system with: npm install -g lighthouse Then run it with: lighthouse You can use Lighthouse programmatically to build your own performance tool or for continuous integration. Make sure to check these Lighthouse-based tools: webpack-lighthouse-plugin: a Lighthouse plugin for Webpack treo: Lighthouse as a service with a personal free plan. calibreapp: a paid service, based on Lighthouse, that helps you track, understand and improve performance metrics using real Google Chrome instances. lighthouse-cTruncated by Planet PHP, read more at the original (another 4631 bytes)[...]






Refactoring Matrix - Qafoo - PHP

Tue, 28 Nov 2017 08:43:09 +0000

When you are beginning to consider refactoring your big legacy codebase towards a new software design, then it is not uncommon to feel helpless after estimating this to be a huge terrifying 2-5 years project. To help solve the problem of not knowing where and how to begin, we have had great success using a decision matrix to decide how each part of the legacy code should be changed in such a refactoring project. Two main factors should influence your refactoring decisions…