php

420 Enhance your calm

planet PHP - 2019-04-10(水) 00:00:00

The 420 Enhance Your Calm status code is an unofficial extension by Twitter.

Twitter used this to tell HTTP clients that they were being rate limited. Rate limiting means putting restrictions on the total number of requests a client may do within a time period.

For Twitter it was useful enough to extend the protocol with a new HTTP status code. However, adding your own HTTP status codes is a bad idea and should generally be avoided.

In many cases it’s possible to express your error condition through one of the exiting status codes. Error statuses that are more unique to your application should simply be communicated via a response body. (for example the standard application/problem+json response).

So when is a new HTTP status code useful? The general idea is that adding a new code to the list is useful if it’s possible for a generic HTTP client to do something with the response.

The idea of having a standard HTTP code for rate limiting was useful enough to be turned into a real HTTP status, So a few years later, we got the 429 Too Many Requests status code, which Twitter ended up adopting too.

カテゴリー: php

Xdebug Update: March 2019

planet PHP - 2019-04-09(火) 22:15:00
Xdebug Update: March 2019
London, UK Tuesday, April 9th 2019, 14:15 BST

This is the first of the monthly update reports in what happened with Xdebug development in this past month. In these reports I will outline what I've been working on the month that has passed. It will be published on every second Tuesday of each month. Patreon supporters will get it earlier, on the first of each month. You can become a patron here.

In February, I worked on the following things:

CI

Xdebug needs testing on many PHP versions, from PHP 7.0.0 to PHP 7.3.3, and the tip of the PHP 7.0 to 7.4 and master branches. Each patch version can introduce changes, and so they all need to be tested against. There are also two different configuration axis: thread-safe vs. non-thread-safe, and 32-bit vs 64-bit. There are currently 37 versions, and with all 4 combinations, that makes 148 configurations to test. If I would test this with Travis CI this would take at least an hour, and with Appveyor it would take at least 16 hours. This is clearly not something that I would like to wait on.

So instead I set up a local CI system, where after each commit I can kick off a script that recompiles and tests all of the configurations. I test the following three variants for each PHP version: 64-bit and non-thread-safe (that's the normal one most people use), 64-bit with thread-safe, and 32-bit with non-thread-safe. My local machine can run 24 tasks in parallel, and the full run of recompiling and testing takes less than 5 minutes.

The results are imported in a MongoDB database that I run on their Atlas hosted server, and the results are read and published by the Xdebug website, where you can see the result of the latest 8 runs.

I still need to add the with-OPcache/without-OPcache access; right now, I only test with OPcache present and loaded. I would also like to add configurations of daily versions of the latest PHP-7.4 and master branches to be able to get PHP API changes, and functional changes before they start breaking PHP.

Bugs

I created stablexdebug_2_7 branch so that I can work on both bug fixes (in xdebug_2_7) and features (in master). There is currently a persistent bug that I discovered while analysing #1646: Excessive error messages for broken pipes. I noticed that although my tests would check for this happening, it would never actually make sure that there were no messages sent to stderr. When enabling this, I encountered issues in the step-debugger tests where I wouldn't correctly detach the debugging session.

These tests are now fixed, but there is now one that produces an elusive crash bug that I haven't managed to track down now.

Beyond the broken-pipe step debugger connection issue, I have also started to make a little bit of progress in addressing #1388: Support 'resolved' flag for breakpoints in cooperation with Jetbrains and the PhpStorm team, who are sponsoring this work.

Podcast

The last thing I wanted to draw your attention to is a new podcast that I started: PHP Internals News. This is a weekly-ish 15 minutes-ish long podcast, where I talk with PHP internals developers about a new RFC, implementations, and upcoming features. It is available on Spotify and iTunes, and an RSS Feed.

So far I have spoken

Truncated by Planet PHP, read more at the original (another 612 bytes)

カテゴリー: php

Interview with Freek van der Herten and Dries Vints

planet PHP - 2019-04-09(火) 17:00:00

@freekmurze

@driesvints Show Notes

Audio

This episode is sponsored by


The post Interview with Freek van der Herten and Dries Vints appeared first on Voices of the ElePHPant.

カテゴリー: php

How to get lines of code in PHP with PHPLoc via CLI or using Docker

planet PHP - 2019-04-06(土) 07:00:00

This video shows how to get the lines of code in a PHP application by using PHPLoc from the command line or using Docker. PHPLoc is a command line application to generate a small but useful report. Adam Culp will show how to use it from a Docker Container using a Docker Image he created. PHPLoc demonstrated on the Concrete5 CMS codebase.

Key Topics:

  • Why find the lines of code
  • PHPLoc is an application to find the lines of code in PHP
  • Different methods to use PHPLoc
  • How to use a Docker image to run PHPLoc
  • Comments as a code smell

Associated Links:
https://en.wikipedia.org/wiki/Code_smell – Code smells explained
https://www.docker.com/get-started – The place for developers to start with Docker
https://hub.docker.com/r/adamculp/php-code-quality – link to the image used to build the Docker container used in this video
https://github.com/sebastianbergmann/phploc – location of the PHPLoc tool
https://www.concrete5.org/ – Concrete5 CMS code I’m using in this video

カテゴリー: php

php|architect: The New Frontend Fundamentals

phpdeveloper.org - 2019-04-05(金) 06:00:02

Eventually, we expose the services offered by the PHP-powered APIs we build to users. Unlike a decade ago when we could count potential client applications on one hand, today the potential client can be anything. But for most people-facing applications, it still means HTML output with images and CSS...

カテゴリー: php

Grav CMS: Permission problems on setup

planet PHP - 2019-04-05(金) 04:27:00

I tried to setup a new site with Grav CMS 1.5.10 and ran into permission problems after unpacking one of the skeleton .zip files. The reason is that on my Linux machine I am running as user+group "cweiske", while Apache is running under "www-data" - and Grav wants to write some files even when it tries to reach the setup check screen.

Grav has a manual page about permissions which is complete nonsense if you want a secure system, and only give the web server process as few writable files and directories as possible. The manual page instructs you to change the permissions and group of every file and directory, which is unneeded.

Errors

Error messages I encountered before the setup check page worked:

Fatal error: Uncaught RuntimeException: Creating directory '/.../cache/compiled/files' failed on error

This is simple:

$ chgrp -R www-data cache $ chmod -R g+w cache/

But now:

Fatal error: Uncaught RuntimeException: Opening file for writing failed on error

No more information. And what's worse: No stack trace, because Grav catches the Exception and throws it again.

The solution is to edit vendor/rockettheme/toolbox/File/src/File.php and let it output the file it tried to write:

- throw new \RuntimeException("Opening file for writing failed on error {$error['message']}"); + throw new \RuntimeException("Opening file for writing failed on error {$error['message']}" . $this->filename);

We now see that it wants to write into user/config/security.yaml.

$ chgrp -R www-data user/config/ $ chmod -R g+w user/config/

And now I saw the setup check page.

Final solution

In the end I had to give this permissions:

$ chgrp -R www-data assets/ backup/ cache/ images/ logs/ system/config/ tmp/ user/accounts/ user/config/ user/data/ user/pages/ $ chmod -R g+w assets/ backup/ cache/ images/ logs/ system/config/ tmp/ user/accounts/ user/config/ user/data/ user/pages/

I'm also disappointed that Grav puts all files publicly available into the server's document root directory, because it does not have a public/ or www/ directory. The issue was closed without a proper solution; Grav's authors chose to patch their .htaccess file instead :/

カテゴリー: php

PHP 7.1.28 Released

php.net - 2019-04-05(金) 01:56:38
カテゴリー: php

symfony Project Blog: New in Symfony 4.3: Configuring services with immutable setters

phpdeveloper.org - 2019-04-05(金) 00:30:01
Contributed by Nicolas Grekas in #30212.

A common need in some Symfony applications is to use immutable services while still using traits for composing their optional features. Although the Symfon...

カテゴリー: php

murze.be: The PHP UK videos have been released

phpdeveloper.org - 2019-04-05(金) 00:00:01

PHP UK is one of my favourite conferences. Unfortunately I couldn't make it this year, but I'll be sure to watch the videos that have been published a little while ago. Here's a cool session on running PHP on AWS Lamba by Neal Brooks

You can watch all other talks in this playlist on YouTube.

カテゴリー: php

Derick Rethans: PHP Internals News: Episode 4: Short Arrow Functions

phpdeveloper.org - 2019-04-05(金) 00:00:01
PHP Internals News: Episode 4: Short Arrow Functions London, UK Thursday, April 4th 2019, 09:04 BST In this fourth episode of "PHP Internals News" we talk to Nikita Popov again (Twitter, GitHub) about his Arrow Functions 2.0 RFC. The...
カテゴリー: php

Laravel News: The 10 Best Laravel Podcasts

phpdeveloper.org - 2019-04-05(金) 00:00:01
Podcasts are a great way of keeping up with your favorite topics and Laravel is no exception. As a community we have a lot of great podcasts to listen to and in this post we highlight ten of the most popular Laravel Podcasts. Visit Laravel News f...
カテゴリー: php

PHP 7.2.17 Release Announcement

php.net - 2019-04-04(木) 23:17:48
カテゴリー: php

PHP 7.3.4 Release Announcement

php.net - 2019-04-04(木) 21:02:16
カテゴリー: php

PHPConf.Asia 2019

php.net - 2019-04-04(木) 13:51:44
カテゴリー: php

PHP 7.2.17 Release Announcement

planet PHP - 2019-04-04(木) 09:00:00
The PHP development team announces the immediate availability of PHP 7.2.17. This is a security release which also contains several minor bug fixes.All PHP 7.2 users are encouraged to upgrade to this version.For source downloads of PHP 7.2.17 please visit our downloads page, Windows source and binaries can be found on windows.php.net/download/. The list of changes is recorded in the ChangeLog.
カテゴリー: php

PHP 7.3.4 Release Announcement

planet PHP - 2019-04-04(木) 09:00:00
The PHP development team announces the immediate availability of PHP 7.3.4. This is a security release which also contains several bug fixes.All PHP 7.3 users are encouraged to upgrade to this version.For source downloads of PHP 7.3.4 please visit our downloads page, Windows source and binaries can be found on windows.php.net/download/. The list of changes is recorded in the ChangeLog.
カテゴリー: php

PHP 7.1.28 Released

planet PHP - 2019-04-04(木) 09:00:00
The PHP development team announces the immediate availability of PHP 7.1.28. This is a security release.All PHP 7.1 users are encouraged to upgrade to this version.For source downloads of PHP 7.1.28 please visit our downloads page, Windows source and binaries can be found on windows.php.net/download/. The list of changes is recorded in the ChangeLog.
カテゴリー: php

Musings, ninja ones: PHP GR8

phpdeveloper.org - 2019-04-04(木) 01:30:02

Fig 1. A chap performing the Detroit JITUnless you have been living under a rock, or are from the past (in which case, welcome), you will be aware that a JIT is coming to PHP 8: The vote ended, quietly, today, with a vast majority in favour of merging into PHP 8, so, it's official.Throw some crazy s...

カテゴリー: php

ページ