PHP Directory


  • How to Calculate VAT in PHP for any EU Country

    By Dave Smith
    As you may know, VAT is a tax used in European Union countries. It is added to the price of products and services, but the actual percentage of the tax varies from country to country, as well from product to product or service to service.

    If you or your clients need to add value-added taxes (VAT) within the European Union or validate VAT numbers, then there is a service available to get the latest rates for each country including rates within reduced rate categories.

    You can also use the service to calculate VAT compliant prices for you, or reverse the calculation to get an amount without VAT if it has already been included.

    Read this article to learn more about how you can use this service to help determine the VAT taxes to use on different purchases using PHP applications.
  • Single-File Symfony Apps? Yes, with MicroKernelTrait!

  • Interview with Jeff Geerling


    Audio only

    The post Interview with Jeff Geerling appeared first on Voices of the ElePHPant.

  • Win a FREE PHPNW ticket

    I've said it before and I'll say it again: PHPNW conference, every first weekend of October in Manchester, is the best PHP conference I've ever been to. I buy my ticket blindly as soon as they go on sale every year. I've been accepted to speak very regularly in previous years and then raffle off my ticket. I was not expecting to need to do that this year, since I did not get accepted to speak. I was looking forward to experience PHPNW as a delegate this year.

    Things have changed though. Unfortunately one of the speakers had to cancel their speaking and I've been asked to be the replacement. Of course I said YES! Speaking at PHPNW is a fantastic experience, and I'll gladly help them in a situation like this. But this also means that I don't need my ticket anymore.

    This means, however, that I have a spare ticket. As it has become a tradition by now to raffle my conference ticket once accepted as a speaker, I'm again raffling my PHPNW ticket. The ticket has full access to all events of the main conference, including the hackathon on Friday, the social on Saturday and the Sunday conference day. The only thing is: The conference is THIS WEEKEND!

    So: If you want to win my ticket, the only thing you need to do is send me an e-mail: Please only send an e-mail if you can actually make it this weekend. On Wednesday I'll do a random draw of the winner and send them an e-mail.

    PHPNW will be awesome again. See you in Manchester!

  • Quick Intro: PhpCompatibility for PHPCS – Are You PHP7 Ready?

  • PHP 7 on macOS Sierra

    PHP 7 on macOS Sierra

    Apple has released the latest version of their OS X operating system to the broad public and many have already upgraded their mac devices. But as it goes with each release, Apple likes to do things a bit different making it quite challenging for PHP developers to stay current with the latest PHP version (or other versions).

    This version of mac OS (11.12) comes pre-installed with PHP 5.6.24.

    PHP 5.6.24 (cli) (built: Aug  8 2016 16:58:37)
    Copyright (c) 1997-2016 The PHP Group
    Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

    Good for Apple, but this version reaches end-of-life support by the end of this year, so it would be great if you could upgrade to PHP 7.0 or even play with the latest PHP 7.1 release candidates.

    Of course you can always turn to Homebrew, XAMMP or whatever package manager you use for easy installations, but taking the compiling path is just as complicated. The failure is equal in most situations.

    Configuring PHP on macOS Sierra triggers the following error:

    apxs:Error: /Applications/ not found!.
    configure: error: Aborting

    In this version of Apple's OS the Apache Portable Runtime was not included. You need to download it and compile it yourself.


    Check the checksums!

    tar -xjf apr-1.5.2.tar.bz2
    tar -xjf apr-util-1.5.4.tar.bz2

    cd apr-1.5.2/
    make install

    cd ../apr-util-1.5.4/
    ./configure --with-apr=/usr/local/apr
    make install

    sudo mkdir -p /Applications/
    sudo ln -s /usr/local/apr/bin/apu-1-config /Applications/
    sudo ln -s /usr/local/apr/bin/apr-1-config /Applications/

    Now you can hapily compile and run the latest PHP version on the latest OS from Apple. See my previous article Compile PHP 7 on Mac OS X 10.11 "El Capitain" for instructions.

    Happy PHP-ing!

  • Mail Logging in Laravel 5.3: Extending the Mail Driver

    Laravel Logo

    One of the many goodies Laravel offers is mailing. You can easily configure and send emails through multiple popular services, and it even includes a logging helper for development.

    Mail::send('emails.welcome', ['user' => $user], function ($m) use ($user) {
        $m->to($user->email, $user->name)->subject('Welcome to the website');

    This will send an email to a new registered user on the website using the emails.welcome view. It got even simpler with Laravel 5.3 using mailables (but the old syntax is still valid). Here's an example:

    # Generate a new mailable class
    php artisan make:mail WelcomeMail
    // app/Mail/WelcomeMail.php
    class WelcomeUser extends Mailable
        use Queueable, SerializesModels;
        public $user;
        public function __construct(User $user)
            $this->user = $user;
        public function build()
            return $this->view('emails.welcome');
    // routes/web.php
    Route::get('/', function () {
        $user = User::find(2);
        \Mail::to($user->email)->send(new WelcomeUser($user));
        return "done";

    Laravel also provides a good starting point for sending mails during the development phase using the log driver, and in production using smtp, sparkpost, mailgun, etc. This seems fine in most cases, but it can't cover all the available services! In this tutorial, we're going to learn how to extend the existing mail driver system to add our own.

    To keep our example simple and straightforward, we're going to log our emails to a DB table.

    Continue reading %Mail Logging in Laravel 5.3: Extending the Mail Driver%

  • Robust Second-factor Authenticationwith PHP

    December 2016 - US
    Presented By

    Tim Lytle
    December 15, 2016
    20:00 CST

    The post Robust Second-factor Authentication
    with PHP
    appeared first on Nomad PHP.

  • shpub - micropub client for the shell

  • PHP and JavaScript Innovation Award Report September 2016 Edition - June 2016 nominees

    By Manuel Lemos
    This is the September edition of the Innovation Award podcast hangout recorded by Manuel Lemos and Arturs Sosins to comment on the outstanding features of all the past month nominees and winners PHP and JavaScript packages, the prizes that the authors earned, starting with the nominees from the month of June 2016.

    Listen to the podcast, or watch the hangout video to learn why the nominated packages were considered to be innovative, as well the current rankings of the Innovation Award Championship by author and by country.

:: Our Favorites

Featured Sites Using PHP

>Atlanta Real Estate