PHP Directory

Blogs

  • Faculty

    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

    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!

  • Whatsapp Chat from CLI Using Puppeteer

    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

    Main Window


    Head over to Whatspup repository and start using it :)

  • Avoid Dependency Injection

    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

    Davey Shafik

    Audio

    Show Notes

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

  • PHP 7.2.0 Released

    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

  • 23 Development Tools for Boosting Website Performance

  • Interview with Bradley Holt

    The post Interview with Bradley Holt appeared first on Voices of the ElePHPant.

  • Refactoring Matrix

    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…

:: Our Favorites

Featured Sites Using PHP

>Atlanta Real Estate