It is very common to forget to apply the code standards before committing. As a result, if you have a GitHub action set up to automatically review them, the action will fail.
Tag: PHP
Installing PHP8.0 on macOS
If you take a look at the PHP supported versions, PHP8.0 is not currently supported.
Displaying information in PHPUnit tests
Sometimes, when you are debugging a PHPUnit test, you need to display some variable or another information in the console.
Translation and localization resources
In this post, I collect some interesting resources to translate and localize software.
Executing only some PHPUnit tests
When you are creating new tests with PHPUnit, if you execute all tests, it can take some time to execute. To execute them faster, you can filter the tests you want to execute.
How to use PHPCS and PHPCBF with a single WordPress file
PHPCS and PHPCBF are two well-know PHP scripts used in the PHP development to (PHPCS) detect violations of a defined coding standard, and (PHPCBF) to automatically correct coding standard violations.
I usually use both with composer in my WordPress projects, adding them as dependency in the composer.json file.
But sometimes I need to check some individual PHP file without adding PHPCS and PHPCBF as dependency. In this post, I am going to explain how I do this.
Documenting GlotPress with phpDocumentor
The current GlotPress API documentation (October 2021) was generated by ApiGen. Last commit was made on April 4th, 2016.
The last ApiGen commit was made on 23 Apr 2018, so I think this tool is deprecated. Furthermore, I was not able to use it with PHP 7.4 and GlotPress, so I look for another tool. The most PHP used tool is phpDocumentor. In this post I explain how to use it with GlotPress.
Install phpDocumentor globally on the machine, using the .phar tool.
cd ~/code/utils mkdir phpDocumentor cd phpDocumentor
Get the last .phar URL.
wget https://github.com/phpDocumentor/phpDocumentor/releases/download/v3.1.2/phpDocumentor.phar
To run phpDocumentor, execute:
php phpDocumentor.phar run \ -d ~/code/wordpress/glotpress-env/glotpress.git \ -t ~/code/wordpress/glotpress-env/gp-docs \ --ignore "vendor/"
Where:
~/code/wordpress/glotpress-env/glotpress.git
is the GlotPress folder.~/code/wordpress/glotpress-env/gp-docs
is the documentation folder.vendor/
is the folder where Composer stores all the information. It is located in the root folder of the project.
Using Composer with a different PHP version than the default one
When you execute Composer, it uses the default PHP version. Sometimes, you will have problems if you use Composer with a different version that the one that executes the project.
Install Composer 2 in a machine with Composer 1
In October 2020, Composer 2 was released. In some servers, I have some projects that need Composer 1 and others that need Composer 2. I will go to explain how to have both versions on the same server.
Incrementar el tamaño máximo de subida de archivo en PHP/WordPress
Si te encuentras con un WordPress u otro software PHP con una limitación de tamaño máximo de subida, resolverlo es muy fácil.