Category: Code

Using Swoole PHP 7.2 Docker image

We all read about Swoole in Laravel-news article, and the results they provided looks nice, this pushed me to create a new Docker image which has PHP 7.2 CLI and Swoole complied with it directly.

In this article am going to show you how you can use it with a simple lumen application, and show you the results I got from using Swoole comparing to using nginx.

1. Creating Lumen Project

First of all, let’s create a simple Lumen project

2. Install Required Packages

Secondly, we need to install the lumen package for Swoole, and made small change

Continue reading

Filed under: Code, docker, Laravel, Nginx, PHP

Installing PHP7.2 with brew on Mac, The new way

Now that homebrew has fully deprecated the old PHP channel and merged everything within the code, things have changed. Before you were able to install anything using a command like brew install php-<package> but now it won’t work anymore.

The new way is simple and easy (not), so follow me:

* First, you will need to make sure the old taps or anything old you have (maybe just moves them to another directory).

* Second, update and clean up your brew installation, run those commands for example:

and fix any issue you see.

* Install PHP via brew by running brew install php which will install PHP 7.2 by default.

* Now the annoying part (for me), which I can’t blame them for it nor I can say anything about, is installing xdebug with pecl , that’s correct we are back to use pecl again

After that running php -v will complain about not finding xdebug and that’s because PHP load the extensions from a directory while PECL installs them in a different one.

In my case PHP loads them from the following path

And PECL installs them at the following path

My simple solution was to symbolic xdebug file to the path that PHP load by running

So my advice for you is to read the log correctly, as this will help you a lot and spare you a lot of time. Also,

remember to run php -m before installing anything.

Filed under: Code, Laravel, PHP

Two tips to speed up bitbucket pipelines

In the past few days, I was playing around with pipelines to see what can I do with it, and how much can I squeeze it to get as much as I can from the functionality they offer. And I wanted to point out to two main things that you can do to speed up your PHP testing a bit, not much but a bit which counts.

First of all, if you don’t use the built-in composer cache functionality, then you need to do that right away, and enabling it is just a small line of code that you add to the test section like

Nothing else, once you have done that you will use the cache they offer and no need to redownload the packages from the internet and the cache will be invalidated automatically after 7 days (if am not mistaken), but this does not mean you don’t have the ability to delete the cache manually. But keep in your mind that each section should use the caches tag otherwise it won’t be useful, sadly Bitbucket pipeline does not offer a global cache feature.

Secondly, remember to install and use hirak/prestissimo package globally, which will give you a nice speed as we all know.

so your file can have something like:

 

Filed under: Code, docker, PHP

New Chatbot project for fun

In the past few days, I decided to try something new so I started to play with bots and created this nice little guy here.

The idea of the project is simple, you ask him about the price of any crypto currency and he will reply back, you can even specify the equivalent currency that you want.

Here is a small video about it.

Let me know what do you think.

Am not going to release it for public yet, first I need to build a good infrastructure for it

Filed under: Code, Laravel, Linux, Other, Personal, PHP, Video

Running Laravel Dusk tests on Bitbucket, the easy way

So today I was trying to run and see if I can manage to get Laravel dusk to run on Bitbucket pipelines, and after too many tests, I was able to do so \(^ ^)/.

In this post I’ll explain the minimum requirements you need to do that, to make things simple, I created a docker image based on PHP 7.2 that you can use directly.

Configure your Laravel project:

After installing Laravel and Laravel dusk (you can read all about it on the docs), you can create a new environment file called .env.dusk which contain the following:

Continue reading

Filed under: Code, docker, Laravel, Linux, PHP