Christian WeiskeTYPO3: Oops, an error occurred! (24.5.2016, 17:43 UTC)

On your TYPO3 production machine (TYPO3_CONTEXT=Production) an extbase plugin crashes and only leaves a cryptic message:

Oops, an error occurred! Code: 201605240939366c16aa1f

If you did not modify TYPO3's error handling , the real error message is logged by TYPO3\CMS\Core\Log\Writer\FileWriter into typo3temp/logs/typo3_*.log.

This does of course not help if you don't have SSH access to the live server. The exceptions also do not follow normal error flow - which means a docker logs -f does not show it, and they will also not show up on your log server.

To fix this, overwrite the default configuration in typo3conf/AdditionalConfiguration.php:

<?php
// configure default logger to log to nginx error log
// so that we'll see this in graylog
$GLOBALS['TYPO3_CONF_VARS']['LOG'] = [
     'writerConfiguration' => [
         \TYPO3\CMS\Core\Log\LogLevel::WARNING => [
             \TYPO3\CMS\Core\Log\Writer\PhpErrorLogWriter::class => []
         ]
     ]
];

Do not try to put this into typo3conf/LocalConfiguration.php; TYPO3 will merge it with the default config, leaving you with both FileWriter and PhpErrorLogWriter. TYPO3's default configuration is defined in typo3/sysext/core/Configuration/DefaultConfiguration.php.

Link
Nomad PHPMake Your Code Do Your Job (24.5.2016, 14:56 UTC)

August - EU
Presented By

Larry Garfield
August 18, 2016
20:00 CEST

The post Make Your Code Do Your Job appeared first on Nomad PHP.

Link
Rob AllenView header and body with curl (24.5.2016, 12:13 UTC)

I recently discovered the -i switch to curl! I have no idea why I didn't know about this before…

Curl is one of those tools that every developer should know. It's universal and tends to be available everywhere.

When developing APIs, I prefer to use curl to view the output of a request like this:

$ curl -v -H "Accept: application/json" https://api.joind.in/
*   Trying 178.208.42.30...
* Connected to api.joind.in (178.208.42.30) port 443 (#0)
* TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate: api.joind.in
* Server certificate: Gandi Standard SSL CA 2
* Server certificate: USERTrust RSA Certification Authority
* Server certificate: AddTrust External CA Root
> GET / HTTP/1.1
> Host: api.joind.in
> User-Agent: curl/7.43.0
> Accept: application/json
>
< HTTP/1.1 200 OK
< Date: Sun, 15 May 2016 11:05:27 GMT
< Server: Apache
< X-Powered-By: PHP/5.6.4
< Access-Control-Allow-Origin: *
< Content-Length: 363
< Content-Type: application/json; charset=utf8
<
* Connection #0 to host api.joind.in left intact
{"events":"https:\/\/api.joind.in\/v2.1\/events","hot-events":"https:\/\/api.joind.in\/v2.1\/events?filter=hot","upcoming-events":"https:\/\/api.joind.in\/v2.1\/events?filter=upcoming","past-events":"https:\/\/api.joind.in\/v2.1\/events?filter=past","open-cfps":"https:\/\/api.joind.in\/v2.1\/events?filter=cfp","docs":"http:\/\/joindin.github.io\/joindin-api\/"}

-v is for verbose and so you get told all the information you could possibly want. However, usually, I only want to know the response's headers and body.

Enter the -i switch!

$ curl -i -H "Accept: application/json" https://api.joind.in/
HTTP/1.1 200 OK
Date: Sun, 15 May 2016 11:10:24 GMT
Server: Apache
X-Powered-By: PHP/5.6.4
Access-Control-Allow-Origin: *
Content-Length: 363
Content-Type: application/json; charset=utf8

{"events":"https:\/\/api.joind.in\/v2.1\/events","hot-events":"https:\/\/api.joind.in\/v2.1\/events?filter=hot","upcoming-events":"https:\/\/api.joind.in\/v2.1\/events?filter=upcoming","past-events":"https:\/\/api.joind.in\/v2.1\/events?filter=past","open-cfps":"https:\/\/api.joind.in\/v2.1\/events?filter=cfp","docs":"http:\/\/joindin.github.io\/joindin-api\/"}

Much better!

-i is for include and from the man page:

Include the HTTP-header in the output. The HTTP-header includes things like server-name, date ofthe document, HTTP-version and more…

This is exactly what I want without the information that I don't!

Link
PHP ClassesInstalling a Database Schema from a JSON format (24.5.2016, 04:37 UTC)
By Samuel Adeshina
Installing a database schema is an important setup task that most PHP applications need to do.

The Scripd package can generate the necessary SQL to install all types of database structures that you may need from the database itself, tables, fields, indexes, stored procedures, views, etc., all from a database independent format based on JSON.

Read this article to learn how to use the Scripd package to generate database independent SQL to install your database schema.
Link
Voices of the ElePHPantInterview with Beau Simensen (24.5.2016, 04:01 UTC) Link
PHP ClassesNotable PHP package: PHP PDF to Text (23.5.2016, 19:35 UTC)
By Manuel Lemos
Many Web applications need to deal with PDF documents and their contents for instance to search for particular text.

However, the PDF format is not easy to analyse and it contains complex structures and often compressed binary data.

The PHP PDF to Text package not only is able to parse the PDF format in pure PHP, but it can also decompress any document objects and extract their page position, making it easy to search PDF documents using only with PHP code, thus without resorting to external programs, special extensions or Web service APIs.

Read this article to learn more details about how this notable PHP package works.
Link
PHP ClassesDetecting Malicious Users behind Anonymous Proxies using IP2Proxy (23.5.2016, 05:03 UTC)
By Elma Dilaver Gheith
Proxy servers are used by many users to bypass Web site restrictions. Sometimes malicious users are hiding behind proxies to commit fraud because a third party anonymous server is hiding their real location.

Fortunately it is possible to detect when users are behind proxies by looking up their IP address using IP2Proxy databases of known proxies.

Read this article to learn how to use IP2Proxy database to detect when users are behind proxies, so you can take the necessary measures to avoid that those users may cause some kind of harm.
Link
Ben Ramsey7 Tips for php[tek] (22.5.2016, 00:00 UTC)

This week, I’m attending php[tek]. This is my seventh php[tek], and the first I’ve attended not as a speaker. It’s one of my favorite conferences, and I didn’t want to miss its first year in a new city: St. Louis. As we gear up for the eleventh php[tek] conference, I thought I’d list my seven tips for getting the most out of your php[tek] experience.

  1. Hang out in the evenings, after the conference sessions.

    php[tek] is known for hosting events in the evening, from video games and board games to hackathons. Make sure you you stick around and take part. One of the best features of PHP is its community, and taking part in the events following the day’s conference sessions is a great way to build relationships in this community.

  2. After the conference events, follow folks to the bar.

    Do you have to be a drinker? Nope. There’s much more to a bar than drinking. In Chicago (Rosemont), php[tek] had Shoeless Joe’s, a nearby sports bar, where attendees would congregate each evening following the conference activities. In St. Louis, I don’t know what that place will be, but I’m certain there will be one. This is where relationship-building continues. There’s so much that can come from these relationships—friendships, business opportunities, mentors, and more!

  3. Take advantage of the “hallway track,” and don’t forget the regular sessions.

    There is a high level of value gained by conversing with other conference attendees in the hallways between (and during) sessions at conferences. This “hallway track” has been touted as one of the most important reasons for attending a conference. The hallway allows you to build relationships and gain better understanding and insight into the technologies and tools you use on a daily basis. It’s an invaluable offering of any conference, but don’t forget about the value gained by attending the sessions. A healthy balance of both will help you have an awesome conference experience.

  4. Attend the morning keynote sessions.

    The morning keynote sessions set the tone for the conference, and this year’s keynotes are no different. While it’s tempting to stay up into the wee hours of the morning—building relationships at the St. Lou

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

Link
Anthony FerraraAll About Middleware (20.5.2016, 21:30 UTC)
Last week, a proposal to standardize middleware for PSR-7 was introduced to the PHP-FIG. The general concept of middleware is not a new one, and has been in use in the PHP world for many years. Several people have raised significant concerns with the proposal, which have gone completely unheeded by the author. Let me go through the most major of these concerns, as well as show what a better proposal might look like.

*Note: All code that will be used in this post is real-world code found in the wild (and linked to) with one exception (X-Powered-By).

Read more »
Link
SitePoint PHPLocalizing Dates, Currency, and Numbers with Php-Intl (20.5.2016, 16:00 UTC)

The first part of this series was an introduction of the PHP Intl extension and of how to localize your application's messages. In this part, we're going to learn about localizing numbers, dates, calendars, and similar complex data. Let's get started!

Globe stock illustration

Localizing Decimals

This may sound odd, but one of my main concerns when formatting numbers is working with decimal points, as they differ from place to place. Check Wikipedia for more details about different decimal mark variations.

Style
1,234,567.89
1234567.89
1234567,89
1,234,567·89
1.234.567,89
1˙234˙567,89
12,34,567.89
1'234'567.89
1'234'567,89
1.234.567'89
123,4567.89

The PHP Intl extension has a NumberFormatter which deals with number localization:

$numberFormatter = new NumberFormatter( 'de_DE', NumberFormatter::DECIMAL );
var_dump( $numberFormatter->format(123456789) );

$numberFormatter = new NumberFormatter( 'en_US', NumberFormatter::DECIMAL );
var_dump( $numberFormatter->format(123456789) );

$numberFormatter = new NumberFormatter( 'ar', NumberFormatter::DECIMAL );
var_dump( $numberFormatter->format(123456789) );

$numberFormatter = new NumberFormatter( 'bn', NumberFormatter::DECIMAL );
var_dump( $numberFormatter->format(123456789) );

string(11) "123.456.789"
string(11) "123,456,789"
string(22) "١٢٣٬٤٥٦٬٧٨٩"
string(30) "১২,৩৪,৫৬,৭৮৯"

The first parameter is the locale code, and the second is the formatting style. In this case, we're formatting decimals.

Continue reading %Localizing Dates, Currency, and Numbers with Php-Intl%

Link
LinksRSS 0.92   RDF 1.
Atom Feed   100% Popoon
PHP5 powered   PEAR
ButtonsPlanet PHP   Planet PHP
Planet PHP