planet PHP

Subscribe to planet PHP のフィード
People blogging about PHP
更新: 8時間 22分 前

Interview with David Laietta

2019-07-17(水) 17:30:00
カテゴリー: php

502 Bad Gateway

2019-07-17(水) 00:00:00

HTTP is a protocol that is implemented by servers and clients, but there is a third category: proxies.

When a system is acting as a proxy for a different server, and that server is misbehaving or doing something unexpected, the proxy can return 502 Bad Gateway to tell a client that the proxy is working fine, but there was something wrong with the ‘origin’ server instead.

A specific example of this could be a CDN in front on a web server, and the web-server is misconfigured and responding with incorrect HTTP responses.

This status should not be used if the origin server just returned a valid HTTP error itself, because these should generally just be forwarded by the proxy (mostly) unaltered.

Example HTTP/1.1 502 Bad Gateway Content-Type text/plain We made a HTTP request to an origin server, but we got a Gopher response back. References
カテゴリー: php

On "10x developers"

2019-07-15(月) 01:58:00
On "10x developers"

Yesterday, a VC posted a Twitter thread about "10x engineers and how to spot them.'' It is a frankly terrible thread, and predictably, it became the latest Internet Pile On(tm), which we all know is Twitter's favorite pastime. I added my own thoughts in another thread, which I want to replicate here for posterity and then expand on a bit more now that I have a real keyboard and not just my phone.

First, here's my original thread, lightly edited for clarity, paragraphs, and links:

Continue reading this post on SteemIt.

Larry 14 July 2019 - 11:58am
カテゴリー: php

PHP 7.4.0 alpha 3 Released

2019-07-11(木) 09:00:00
PHP team is glad to announce the release of the third PHP 7.4.0 version, PHP 7.4.0 Alpha 3. This continues the PHP 7.4 release cycle, the rough outline of which is specified in the PHP Wiki. For source downloads of PHP 7.4.0 Alpha 3 please visit the download page. Please carefully test this version and report any issues found in the bug reporting system. Please DO NOT use this version in production, it is an early test version. For more information on the new features and other changes, you can read the NEWS file, or the UPGRADING file for a complete list of upgrading notes. These files can also be found in the release archive. The next release would be Beta 1, planned for July 25th. The signatures for the release can be found in the manifest or on the QA site. Thank you for helping us make PHP better.
カテゴリー: php

501 Not Implemented

2019-07-10(水) 00:00:00

A server can return 501 Not Implemented when it doesn’t support a certain feature.

The RFC specifically lists ‘not supporting a specific HTTP method on any resource’ as an example of this.

In most practical cases this is similar enough to 405 Method Not Allowed, and 405 is probably the clearer status code for most cases.

But there is a difference. Given that 5xx are server-side errors and 4xx errors are client-side errors, it could be argued that emitting a 405 means that a method should never really have been called by a client, but a 501 could mean that the method should have worked, but the server has incomplete functionality.

I sometimes use 501 during development of new API’s as a ‘stub response’ for features I intend to build, but haven’t built yet.

Example HTTP/1.1 501 Not Implemented Content-Type text/html <img src="http://geocities.example/work-in-progress.gif" /> References
カテゴリー: php

Interview with Adam Kelso

2019-07-09(火) 20:30:00
カテゴリー: php

Xdebug Update: June 2019

2019-07-09(火) 17:34:00
Xdebug Update: June 2019
London, UK Tuesday, July 9th 2019, 09:34 BST

This is another of the monthly update reports in which I explain what happened with Xdebug development in this past month. It will be published on the first Tuesday after the 5th of each month. Patreon supporters will get it earlier, on the first of each month. You can become a patron here to support my work on Xdebug. More supporters, means that I can dedicate more of my time to improving Xdebug.

In June, I worked on Xdebug for 20 hours, a little bit less than normal as I spend some time on holidays and conferences. I worked on the following things:

2.8.0alpha1 Release

I made the 2.8.0alpha1 release just when the month was running out.

This alpha release adds preliminary support for PHP 7.4, but also addresses some other issues. It also includes a major overhaul on how I do SKIPIF sections in the phpt tests that I used to test Xdebug.

Instead of having complicated sections such as:

<?php if (!version_compare(phpversion(), "7.0.12", '>')) echo "skip > PHP 7.0.12, < PHP 7.1 needed\n"; ?> <?php if (!version_compare(phpversion(), "7.1", '<')) echo "skip > PHP 7.0.12, < PHP 7.1 needed\n"; ?> <?php if (!extension_loaded('zend opcache')) echo "skip opcache required\n"; ?>

I now have:

check_reqs('PHP > 7.0.12,< 7.1; opcache');

This makes it a lot easier to maintain Xdebug's tests among multiple PHP versions. After all, I still support PHP versions since PHP 7.0—although I am considering dropping support for PHP 7.0 and only support PHP 7.1 and up.

This release also features the Resolving Breakpoints feature, which the folks at Jetbrains have sponsored. After their last review, I made a few modifications to run the resolver for newly set breakpoints as well. I am intending to create a separate blog post on what this new feature solves.

I also found an already existing bug with return breakpoints, where a return breakpoint would not cause a break immediately. A fix for this is also in the alpha1 release.

32-bit Support

I am considering to stop creating Windows binaries for 32-bit installations of PHP. It duplicates the amount of time that it takes to create Windows binaries, slowing down, testing on CI, and the creation of releases as it takes ~2 hours to build them all on AppVeyor.

The reasoning behind this is that very few people still use 32-bit Windows installations, and I am not sure it's still worth spending time on it. I ran a little Twitter poll about this.

Although even if I would drop 32-bit binary creations, users that still need these binaries can get them on the PECL website. PECL builds extensions for all the supported PHP versions, such as here for Xdebug 2.8.0alpha1

Podcast

I have been continuing with the PHP Internals News podcast. In this weekly podcast, I discuss in 15-30 minutes, proposed new features to the PHP language with fellow PHP internals developers. It is available on Spotify and iTunes, and through an RSS Feed. Let me know if you are a listener!

カテゴリー: php

Interview with Adam Harvey

2019-07-09(火) 15:03:00
カテゴリー: php

Interview with Adam Harvey

2019-07-09(火) 01:01:00
カテゴリー: php

JsonMapper 1.5 released

2019-07-07(日) 21:40:00

Now that the kids are with their grandparents for a week, I finally had the time to merge pull requests and tinker on bug reports myself.

Today I released JsonMapper version 1.5.0, one and a half year after 1.4. It got support for PHP 7 scalar type declarations, and improves class map handling. Some common fatal errors are prevented by throwing an exception with a message that is easier to grasp.

I also shut down my PEAR channel, zustellzentrum.cweiske.de. JsonMapper is now only available via packagist.

カテゴリー: php

Interview with Adam Harvey

2019-07-04(木) 14:03:00
カテゴリー: php

PHP 7.3.7 Release Announcement

2019-07-04(木) 09:00:00
The PHP development team announces the immediate availability of PHP 7.3.7. This is a bug fix release.All PHP 7.3 users are encouraged to upgrade to this version.For source downloads of PHP 7.3.7 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.2.20 Released

2019-07-04(木) 09:00:00
The PHP development team announces the immediate availability of PHP 7.2.20. This is a bugfix release.All PHP 7.2 users are encouraged to upgrade to this version.For source downloads of PHP 7.2.20 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

Running PHP applications on Azure App Engine

2019-07-03(水) 19:02:00

Azure App Service is a way to host your web application in a container without having to think about the server. It's the same PaaS concept as AWS Elastic Beanstalk and supports all the main web programming languages. It also supports Windows and Linux OS containers.

I have a client that is moving an on-premises PHP application to App Service and so have been looking at what I needed to do to deploy it there.

To get started, Azure have a couple of great tutorials for Linux and Windows with which I got a basic app running in no time, so I could turn my attention to the specifics I cared about.

Database drivers

My app uses SQL Server, so I was pleased to see that both the Windows and Linux PHP containers have the sqlsrv extension installed. However, there's a bug today where the Linux container is missing the ODBC driver, so SQL Server support doesn't actually work on the Linux container. This should be fixed in July apparently.

Both containers also support PostgreSQL and MySQL, so the databases I care for are covered.

Rewriting all URLs to index.php in the public directory

In common with many PHP applications, I have a public directory where the files to be served by the web server are kept and my PHP and other source files are elsewhere. I also use rewriting to map all URLs to my public/index.php file.

The way we handle this depends on the container.

Windows container

On the Windows container, we need to change the path mapping so that the public directory is mapped to the /. This can be done in the web portal in Configuration -> Path mappings where by default the / virtual path is mapped to site\wwwroot physical path. Edit this so that it points to site\wwwroot\public. I'm not a fan of web-based tooling for things like this as it's error-prone. Azure provides a command line tool, so we can make the same path mapping change with:

$ az resource update --name web --resource-group {Resource Group} \ --namespace Microsoft.Web --resource-type config --parent sites/{App Service} \ --api-version 2015-06-01 \ --set properties.virtualApplications[0].physicalPath="site\wwwroot\public"

(Change {Resource Group} and {App Service} to the correct names for your installation.)

Now that we're serving from /public, we can now add the rewrite rule. With IIS, we use a web.config file:

/public/web.config:

<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="Pretty URLs to index.php" stopProcessing="true"> <match url="^(.*)

quot; />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

Linux container

On Linux, the container runs Apache, so we can rewrite the URL to public/index.php with a single .htaccess file in our root directory:

/.htaccess:

RewriteEngine On RewriteBase / # Rewrite static files that live in public/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)\.(woff|ttf|svg|js|ico|gif|jpg|png|css|htc|xml|txt|pdf)$ /public/$1.$2 [L,NC] # Redirect all other URLs to public/index.php RewriteRule ^((?!public/).*)$ public/index.php/$1 [L,QSA]

Two rewrite rules are required: firstly we rewrite static files so that the continue to be served by Apache and then we rewrite everything else to index.php.

Environment variables

Environment variables are a common way to set per-installation configuration and this is done vie the portal or the command line:

$ az webapp config appsettings set --name {App Service} \ --resource-group {Resource Group} \ --settings \ ENV_VAR_1="some value" \ ENV_VAR_2="some other value"

Summary

Running a PHP application on Azure App Engine with either the Windows or Linux container is much the same as on any other hosting and seems to work well.

カテゴリー: php

Building what’s in front of you

2019-07-03(水) 04:42:00

Recently while working on an application I found myself asking a number of architectural questions. These were questions about things that I might consider “fundamental” – elements of the application, how many methods each class might receive, and how to put it all together into something cohesive. You might have asked yourself some of the […]

The post Building what’s in front of you appeared first on BrandonSavage.net.

カテゴリー: php

500 Internal Server Error

2019-07-03(水) 00:00:00

While the 4xx-series errors are specifically for client-side errors, the 5xx-series errors are for server-side errors.

A server-side error generally means that there is a bug or outage. If you are developing a client and you encounter a 5xx-range error, generally you can assume it wasn’t your fault, and it might even be worth contacting the maintainers of the web service you’re trying to use.

The first error in this series is 500 Internal Server Error. This is a generic error, and a good error to choose if there is not a more specific error suitable for your problem.

Many server-side error handlers automatically convert any uncaught exception into this error code.

Example HTTP/1.1 500 Internal Server Error Content-Type text/plain We broke it, sorry! References
カテゴリー: php

ページ