~/devreads

#php

72 posts

6 Jun

3 Mar

Rob 2 min read

Recently I discovered that this code passed our PHPStan level 10 checks: use http\Exception\InvalidArgumentException; // ... throw new InvalidArgumentException; I was surprised as http\Exception\InvalidArgumentException is not a class in our system. While cooling, I discovered that there's an http PHP extension and it appears that PHPStan has a stub for this which means that it accepts it as existing even…

php

6 May 2025

Rob 1 min read

On the Roave Discord recently, there was a discussion about not breaking BC in interfaces inspired by this post by Jérôme Tamarelle: It's clearly true that if you add a new parameter to a method on an interface, then that's a BC break as every concrete implementation of the interface needs to change their signature. However, Gina commented that you…

php

25 Feb 2025

Rob 3 min read

One of the bigger changes in PHPUnit 10 was the introduction of the new extension system which replaced listeners and hooks. The old way On one of my projects we have a TestListener that sets up the database before we run some functional tests against it. It looks like this: <?php declare(strict_types=1); namespace App\Test\Listeners; use App\Test\Functional\Helpers\DbHelper; use PHPUnit\Framework\TestListenerDefaultImplementation; use PHPUnit\Framework\TestSuite;…

php

24 Sept 2024

Rob 1 min read

When Guzzle throws BadResponseException, the message includes information about the method, URL response code and then a truncated part of the body. For example: "Client error: `GET https://dev.clientproject.com:4444/oauth2/authorize?client_id=983e98d2fab8756a&scope=scope&response_type=code&redirect_uri=%2Fhome&code_challenge=some_code_challenge_here` resulted in a `400 Bad Request` response: {"error":"invalid_request","error_description":"The request is missing a required parameter, includes an

php

17 Sept 2024

Rob 1 min read

Recently, I set up my PHP dev environment to allow me to step debug from unit tests that I run with make unit The relevant parts of Makefile look like this: # Set DEBUG=1 to enable Xdebug ifeq ($(origin DEBUG),undefined) XDEBUG := else XDEBUG := XDEBUG_SESSION=PHPSTORM endif unit: ## Run unit tests docker compose exec php bash -c "$(XDEBUG) vendor/bin/phpunit…

developmentphp

10 Sept 2024

Rob 2 min read

I'm working on a project that uses MS SQL Server as its database. Recently, I noticed that the SQL Server Docker container now works with Apple Silicon Macs, so looked into setting up a PHP-FPM container with the sqlsrv extension installed. I'm noting the relevant parts of my Dockerfile for when I need them again, so this is entirely an…

developmentdockerphp

3 Sept 2024

Rob 3 min read

For one project that I'm working on the PHP-FPM-based Docker container is built from a Ubuntu container with PHP is installed into it. A little like this: FROM ubuntu:22.04 RUN apt-get update && apt-get upgrade -y && apt-get install -y gnupg curl # Register the Ondrej package repo for PHP RUN mkdir -p /etc/apt/keyrings \ curl -sS 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x14aa40ec0831756756d7f66c4f4ea0aae5267a6c' | gpg…

developmentdockerphp

25 Jun 2024

Rob 1 min read

When I write integration tests with PHPUnit, I find it helpful use Monolog's TestHandler to check that the logs I expect are generated. It's reasonably common that classes that write to a log take a PSR\Log\LoggerInterface in their constructor and then use that for logging. This usually logs to the error handler for pushing to Sentry or whatnot. This makes…

php

9 Apr 2024

Rob 1 min read

With some commercial projects, it can be useful to know that all your dependencies have licences that your organisation deems acceptable. I had this requirement for a few clients now and came up with this script that we ran as part of our CI which would then fail if a dependency used a license that wasn't allowed. This proved to…

php

26 Mar 2024

Rob 2 min read

In order to verify a JWT created with an asymmetric key, the verifier needs to get the correct public key. One way to do is described in RFC7517 which describes the JSON Web Key format. Within the header of the JWT there is a kid property which is the key ID which is then used to find the correct key…

php

19 Mar 2024

Rob 3 min read

The most common use of JWTs is as an authentication token, usually within an OAuth2 workflow. Creating these tokens is part and parcel of the authentication library that you use. I recently had a requirement to use a JWT independent of authentication and these are some notes on what I learned when researching with Lcobucci\JWT. Make up of a JWT…

php

21 Jun 2023

srinivas.tamada@gmail.com (Srinivas Tamada) 1 min read

In this post, I will explain the steps to deploy a simple PHP email MX record validation application on AWS lambda function using Bref layers. AWS Lambda natively supports Java, Go, PowerShell, Node. js, C#, Python, and Ruby code, not PHP. You can deploy the lite weight PHP function to improve the application performance and it will reduce cost compared…

deployfunctionlambdaphpserverless

21 Feb 2023

Rob 2 min read

I have just returned from the 2023 edition of PHPUK and, as always, found it a valuable conference to catch up with the PHP community and find out what’s happening in the ecosystem. This year, I was accepted to speak on the differences between RPC, REST and GraphQL APIs and was surprised and gratified that the room was at full…

conferencesphp

15 Oct 2021

srinivas.tamada@gmail.com (Srinivas Tamada) 1 min read

Nowadays most of my side projects are managed with Github. It has more advantages and flexibility to manage file versions. I am following a different webhook system to automatically deploy my old PHP projects. Not sure about the standards, but the following solution is an alternative approach that may solve your deployment problem for every Github push.

githubphpwebhook

8 Aug 2021

srinivas.tamada@gmail.com (Srinivas Tamada) 1 min read

Few days back one of my friend's project database credentials got exposed. After some investigation, we realized that it is because of the .git config commit. I would recommend configuring your sensitive credentials with operating system environment variables. This way you can protect information from the code base. This post will explain how to set up an environment variable for…

apacheenvironmentphpubuntuxampp

7 Aug 2019

srinivas.tamada@gmail.com (Srinivas Tamada) 1 min read

Microsoft Azure is another great alternate cloud service and it is offering a one-year free trial with $200 credit. This post is almost similar to my previous Cloud service article. This will explain to you how to set up a virtual machine instance with secure firewall rules and setting up a XAMPP(PHP Maria DB Server) using the Ubuntu operating system.…

azurecloudhostingmicrosoftphp

30 Jul 2019

srinivas.tamada@gmail.com (Srinivas Tamada) 1 min read

Google cloud platform is a cloud computing service and a perfect alternate for Amazon Webservices. Nowadays most of the top companies are moving towards Google services for better results. Google cloud platform is offering a $300 free trial for one year. This post is about how to set up VM instances with firewall rules in addition to creating a XAMPP…

cloudgooglephpubuntuweb services

18 Dec 2018

8 min read

In a previous post, Docker PHP/PHP-FPM Configuration via Environment Variables, I described how to use environment variables to configure PHP FPM and CLI. With my method you can override one of over 650 PHP INI settings. More INI settings are but a PR away! In a more recent post, PHP Modules Toggled via Environment Variables I extended this concept to…

dockerphpnginxapacheblog

14 Dec 2018

8 min read

In my previous post, Docker PHP/PHP-FPM Configuration via Environment Variables I introduced my new PHP image that uses environment variables to configure its INI settings. The Dockerfile is a beast, to be sure. At over 650 lines it documents my attempt at bringing true flexibility to an immutable PHP image. With it, you can set any number of PHP INI…

dockerphpblog

15 Nov 2018

10 min read

ed: If you want to run the containers right now, jump ahead to How to Use the Images. For several months now I have been working on PuPHPet.com’s replacement. It is a Docker-based GUI functionally similar to PuPHPet. Docker, like Vagrant, allows sharing directories and files from the host to the container/VM. Unlike Vagrant, Docker images are easy to create,…

dockerphpblog

23 Jul 2018

6 min read

A quick history ed: If you want to jump right to the solution, jump ahead to Nginx map. Docker for Mac is very slow. It is so slow that I purchased a new Dell XPS laptop and for the first time in 6 years am now using a non-MacOS (Fedora) machine as my daily driver. Not everyone has the luxury…

webdevserverphpxdebugdocker

7 May 2018

Junior Grossi 4 min read

Laravel is a PHP framework that uses Eloquent, a powerful and amazing ORM that allows you to do complex SQL queries in a very easy way. But sometimes you need more, and here I’m gonna give you an interesting tip that can bring you a lot of flexibility. When dealing with simple database queries in … Continue reading Querying and…

laravelphp

30 Apr 2018

23 Apr 2018

Junior Grossi 10 min read

Having a clean code with single responsibility is important, and doing that for model filtering can be easy and very powerful. Believe me. This blog post is related to a talk I gave on April, 2018 on Darkmira Tour PHP 2018, in Brasília/DF, Brazil, with the same title. The slides are on SpeakerDeck. Filtering models … Continue reading QueryFilter: A…

laravelopen sourcephptalks

26 Mar 2018

Junior Grossi 5 min read

Maintaining an open source project – even a small one – is not an easy task. The open source ecosystem is about sharing and contributing, about giving and receiving. You scratch my back and I will scratch yours. Open-source is not only a free and open software, it’s a lifestyle. Working with open-source is working … Continue reading Open-source is…

open sourcephpprogramming

12 Mar 2018

Junior Grossi 6 min read

Learn how to use a very simple and efficient service called ServerPilot for provisioning a web server to host your next PHP project or blog. Provisioning a well-configured web server for a PHP application is not an easy task. You can have experience doing that, but this is not my strongest skill, I admit. So … Continue reading Easy server…

mysqlphpweb server

5 Mar 2018

Junior Grossi 8 min read

Being really good in your field is important, but more important than that is to seem to be good. Invest in yourself. Be searchable! How many times did you search your name on Google? How many times did you search some keywords related to you? Did you like the results you got? Can them be … Continue reading Invest in…

careersphp

26 Feb 2018

Junior Grossi 6 min read

Open source can change your life. It has changed mine with Corcel, an open source project I started in 2013 that changed who I am, and how I live. The first title I gave to this post was How open source can change your life for the better. That was a good title too, but I … Continue reading Why…

open sourcephp

16 Feb 2018

Junior Grossi 4 min read

Learn how to configure XDebug and PHPUnit in PHPStorm, allowing you to write better tests and fix bugs faster. Test Driven Development (TDD) is an old topic, I know, but it seems many people don’t understand how it makes you write better code. The point here is that one of the most important benefits it’s … Continue reading Using XDebug…

phptddxdebug

23 Mar 2016

25 Jul 2015

Luciano Mammino 15 min read

This post highlights 6 important rules to keep in mind when developing performant web applications: avoid premature optimization, do the minimum required work, defer non-critical tasks, leverage caching, avoid N+1 queries, and design for horizontal scaling. Following these guidelines will help you write efficient code from the start and build apps ready to handle growth.

phpsymfonylaravelperformancescalability

24 Jul 2015

Schakko 1 min read

For two weeks I have been heavily developing a new web application based upon Laravel. Tonight I searched for an easy filtering solution like Zend_Filter so that the request strings are automagically trim’d, lowercased, and so on. Lucky me, the repository https://github.com/rmasters/filter is available with a composer.json but latest commit […] The post Using GitHub forks or local Git repositories…

php

18 Apr 2015

27 Feb 2015

21 Feb 2015

13 Jan 2015

Junior Grossi 5 min read

Hi everybody! Here I’m again to write my first post in 2015. Last year I’ve wrote less and this year I have plans to write much more, telling about my experience with web development. I have plans to start screencasting too, but this is just plans 😀 I decided to start this year writing about … Continue reading Why WordPress…

phpwordpress

13 Jun 2014

26 Apr 2014

Junior Grossi 5 min read

Hi everybody! Updated Mar 3rd 2015: Are you using Laravel 5? Check these changes! Updated May 11th 2014: Using Corcel project Currently I am working on a project where I had to make some choices about technologies and how work with them together. First this project will be developed using WordPress only. It’s a College … Continue reading Working with…

laravellaravel 4phpweb serverwordpress

11 Apr 2014

Luciano Mammino 1 min read

ORM Cheatsheet is a useful website that serves as a quick reference guide for developers struggling to remember how to use common PHP ORM libraries like Doctrine 2 and Propel. It provides examples for annotations, relationships, and configuration.

phpdoctrineorm

15 Mar 2014

Luciano Mammino 9 min read

This article shows how to build a simple command line application using the Symfony Console component and Pimple dependency injection container. It provides a step-by-step guide on structuring the code, defining services, configuring parameters and wiring everything together to create a executable console app.

phpsymfonyconsolepimple

28 Feb 2014

Luciano Mammino 3 min read

The post explains how to integrate twig.js with BazingaJsTranslationBundle to handle translations consistently between PHP and JavaScript. It shows how to build a custom Twig extension to translate strings with the Bazinga Translator object and handle differences in parameter formatting.

phpsymfonyjavascripttranslationtwig

14 Feb 2014

10 Feb 2014

6 Nov 2013

Junior Grossi 2 min read

Let’s supose you want to develop your own URL shortener, like Bit.ly for example. You can, of course, use the ID as a integer, like, 1, 2, 3, etc. If you have 12.345 rows in your database table, you will need 5 digits, like http://example.com/12345. Large applications like Youtube, have much more entries, so, to … Continue reading Generating IDs…

php

4 Nov 2013

Junior Grossi 4 min read

Generally assets are stored in your public directory, right? They are public, so anyone can get access to them. But nowadays the performance is a very important factor when deploying a new app. I strongly recommend you to minify and cache your assets, like CSS files, Javascript files and Images. If you are using 11 … Continue reading Managing assets…

composerlaravellaravel 4php

14 Oct 2013

Junior Grossi 1 min read

One of the best improvements of the PHP 5.4 was the built-in web server. Like in Ruby On Rails, now you do not need Apache or Nginx inside your development machine. To start a web server is easy: php -S localhost:8000 Remember you can choose the port you want. You can use localhost:8000 or localhost:8080 … Continue reading Working with…

laravellaravel 4php

25 Sept 2013

Junior Grossi 6 min read

Actually this post is a outflow and at the same time an advice. I have seen some PHP developers that are completely OUT of what is happening in the PHP world, besides committing some mistakes that cannot be accepted. PHP 5.3+ If you are entitled as a PHP developer you must to update. In my … Continue reading Be a…

php

18 Sept 2013

Junior Grossi 1 min read

These days I’m thinking about productivity and the use of PHP frameworks. I’ve read some posts about framework X or Y, defending a framework instead of another one. I know people that use a framework like Zend Framework to develop a simple website just to say they’re using it, and not an “easy” framework. I … Continue reading Solve the…

composerlaravelphpwordpresszend framework

24 Jun 2013

Junior Grossi 4 min read

Hi all! Today I am starting a post series about Design Patterns. I have wrote about them a lot but only suggesting you to learn about to be a better developer. I am studying them, so nothing better to write about and improve my knowledges too. I only ask you to read everything to understand … Continue reading Design Patterns…

design patternsphp

21 Jun 2013

Junior Grossi 2 min read

Hello again! It’s my second post today! I’m electric! I am developing a project that uses a package I’m developing too. So, it is a real time test project. I find a new way to do something and write it inside my package and uses that. But sometimes this is a boring work. I am … Continue reading Testing your…

composerphp

Junior Grossi 3 min read

Hi guys! Everyone wants to contribute in some way with developers. Maybe you’re thinking in a project to develop and share but you search at Google and find someone who already did that. Maybe the answer to this problem is in front of you. Everything you do can be reused in a future project. If … Continue reading Contributing with…

php

7 Mar 2013

Junior Grossi 4 min read

Hi everybody! Today I’ll write about how you can contribute with PHP community creating packages (or updating your’s) using Composer and Packagist. First, if you’re a PHP developer and don’t know yet what is Composer, take a look on the post Why you should use Composer and how to start using it to get more … Continue reading Creating your…

composerphp

26 Jan 2013

Junior Grossi 6 min read

Hello! One of the most big changes happening in PHP world is the Composer. I’m shure you heard about it but maybe you don’t know why you should use it and how much it is good for you and your projects. What is Composer? When you need some specific code in PHP you can go … Continue reading Why you…

composerlaravelphp

25 Jan 2013

Junior Grossi 3 min read

Hello! Today I had to update a project that was developed using WordPress and PHP 5.3. Today I have PHP 5.4 installed on my machine and this newer version abandoned some old features, and you have some Fatal errors like Call-time pass-by-reference has been removed. The solution was go back to PHP 5.3 and do … Continue reading Working with…

apachephp

22 Jan 2013

Junior Grossi 3 min read

Hello everyone! Use or not to use a PHP Framework on your new projects? Here I’ll talk about my personal opinion about that and I wish help you. First, I have a simple concept about languages and respectives frameworks: a framework must make the development simpler. Every software has a single purpose: work! This is … Continue reading Why you…

composerlaravelphp

11 Oct 2012

Junior Grossi 3 min read

Hello! Laravel is an awesome PHP framework created by Taylor Otwell. Actually, it is on the third version and it is one of the great PHP frameworks we have today. As a lot of frameworks, we have to create our own Apache Virtual Host to point to the public dir to improve security and only … Continue reading Deploying Laravel…

laravelphpuncategorized

19 Sept 2012

Junior Grossi 4 min read

Hello all! Let’s continue with our WordPress series. Today I’ll write about the main files in a WordPress theme. First files Above we have some files that are basic for your new theme: index.php This file is the root file, the home page. When you open your WordPress website it’ll get this file content. Is … Continue reading Creating your…

phpwordpress

15 Sept 2012

Junior Grossi 3 min read

Hello everyone! As I said, this is our second post about Themes in WordPress. Today I’ll talk about: How to create page templates How to retrieve posts If you want you can read the first post about WordPress themes. Let’s GO! Page Templates You can customize pages the way you want, as you want. If … Continue reading Creating your…

phpwordpress

13 Sept 2012

Junior Grossi 3 min read

Hello again… Continuing with our first WordPress site, now we’ll understand how WordPress allow you to customize themes. If you didn’t read the first post about WordPress Thinking the WordPress Way – First Steps and want to learn how WordPress works, take a look. You don’t have to change your layout or using specific techniques … Continue reading Creating your…

phpwordpress

Junior Grossi 2 min read

Hello everybody! I work with PHP since 8 years and I never took a look on WordPress. In the start of this year a customer requires me to develop his next website, but using the WordPress. So I had to search some tutorials on the Internet and join informations to make my own way to … Continue reading Thinking the…

phpwordpress

13 Dec 2011

Junior Grossi 2 min read

Hello. Another quick tip. To start a new Zend Framework project, the easiest way is using Zend_Tool for that. Please, install first the Zend_Tool follow this link at Zend Framework documentation page. Creating new project Let’s starting using the command line and creating a new ZF project. zf create project my_project_name Zend_Layout Now, get in … Continue reading Creating new…

phpprojectzend frameworkzend tool

Junior Grossi 1 min read

Hi all. Here I am again. Today I have a quick tip for beginners using Zend Framework. Do not insert pre and post code (for database) in your Controller. The Zend_Db_Table_Row is for that. Lets create our DatabaseTable class for Posts: /** * Located in .../models/DbTable/Posts.php */ class Posts extends Zend\_Db\_Table_Abstract { protected $_primary = … Continue reading Pre and…

databasephpzend frameworkzend dbzend db table

20 Jul 2011

Junior Grossi 2 min read

Hello everybody! Usually I have direct access (shell) in all the servers that host my Zend Framework applications, but, some clients already have a shared host, so I have to deploy the application there too. I was thinking how can I never thought this before! There are a lot of ways to deploy a Zend … Continue reading Deploying Zend…

hostingphpzend frameworkzf

15 Jul 2011

Junior Grossi 2 min read

Hi every one! I just read a small but very interesting post in BrownPHP website with a comparison between Zend Framework and CakePHP Framework. The post is below and the original article is here. The Zend Framework, developed by Zend Technologies is an open-source, object oriented web-application framework implemented in PHP 5. It is widely … Continue reading Zend Framework…

cakephpphpzend frameworkzf

13 Jul 2011

Junior Grossi 6 min read

Hi everyone, Here I am again. Yesterday a friend asked me how to create the basics CRUD (Create, Release, Update, Delete) operations using Zend Framework. As everybody now, a basic CRUD it’s a good way to understand some framework’s resources to a new ZF developer. As he is a newbie with Zend Framework, the example … Continue reading Basic CRUD…

crudphpzend frameworkzf

11 Jul 2011

21 Jun 2011

Junior Grossi 3 min read

Boa tarde, pessoal! É muito comum em aplicações web a necessidade de trabalhar com imagens, tanto para redimensionamento, criação de thumbnails, girar, etc. Apresento a Asido, um conjunto de classes para trabalhar com imagens em PHP. Embora eu não goste muito da forma de organização de OO que a Asido utiliza, é uma boa ferramenta … Continue reading Redimensionamento, rotação…

asidogdimagemagickimagensphp

Junior Grossi 2 min read

Olá pessoal! Esta semana estou trabalhando num projeto onde a utilização de Ajax está sendo muito útil em termos de performance e facilidade na busca de produtos no banco de dados. Como estou utilizando Zend Framework no projeto, vou explicar resumidamente como trabalhar com requisições Ajax no ZF. Basicamente, o óbvio seria desabilitar a renderização … Continue reading Utilizando AjaxContext…

ajaxphpzend frameworkzf

16 Jun 2011

Junior Grossi 2 min read

Olá pessoal. Indo direto ao assunto, sempre tive dúvidas quanto a usar o Poedit para traduzir strings, motivo pelo qual usava mais arrays em PHP mesmo. Porém, mais cedo ou mais tarde, necessitamos evoluir e correr atrás do tempo perdido. Sempre achei o Poedit chato e nunca conseguia fazê-lo funcionar. Após umas fuçadas na net … Continue reading Tradução usando…

gettexti18nphppoeditzend framework

31 Mar 2011

Schakko 1 min read

As I mentioned yesterday, Christoph is currently developing the Active Directory Integration WordPress plugin. Today we were talking about the write back of WordPress profile settings to Active Directory. I mentioned it would be helpful to have an abstract definition of available Active Directory attributes which can be dynamically integrated […] The post Convert Active Directory schema to XML or…

active directory ldapphpactive directoryconvertjson