Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Emir Karsiyakali:
Quick Tip - Logging Mastery with Laravel
Jul 02, 2018 @ 18:54:11

In this new post to his site Emir Karsiyakali shares a quick tip for the Laravel users out there to improve your logging output and make following requests easier.

Putting unique id to requests one of my silver bullet while designing RESTful APIs. It provides an extremely easy way to follow each request’s lifecycle while debugging. In this guide I’ll show you how you can add it to your log files on Laravel 5.6.

Under the hood, Laravel utilizes the Monolog library, which provides support for a variety of powerful log handlers. Laravel makes it a cinch to configure these handlers, allowing you to mix and match them to customize your application’s log handling.

He starts with adding the "tap" value to the logger configuration and pointing it to a newly created LocalLogger class. He shows the implementation of this logger class including a custom log formatter that will modify the log string to add the unique ID after the "datetime" value. He also includes some usage examples in your Laravel code, putting the Log::info line into a LogRequestResponse middleware to be executed on each request.

tagged: laravel tutorial log unique id monolog

Link: https://emirkarsiyakali.com/quick-tip-logging-mastery-with-laravel-7282988032a7

DevShed:
Inserting Comments and Accessing Nodes with the DOM XML Extension in PHP 5
Mar 11, 2008 @ 20:40:21

DevShed continues their series looking at using the DOM extension in PHP5 to work with XML in your application. They've already looked at adding attributes and creating CDATA information in a new DOM document. This time they build on that and also include new methods - appending comment nodes and getting at XML nodes by their IDs.

I'm talking about the DOM XML extension, which allows you to handle XML documents by using the DOM API. Thus, if you're interested in learning how to put this extension to work for you quickly, look no further, because you've come to the right place. [...] In this third installment of the series, I'll be teaching you specifically how to append comment nodes to a given XML string and how to extract certain elements via their IDs.

They review the method to add attributes and CDATA to an XML document first. Then they cover the other two new topics - appending comment nodes and grabbing nodes by their ID attribute.

tagged: dom extension php5 node cdata attribute id fetch tutorial

Link:

Graham Bird's Blog:
Extra-pretty URLs with slugs
Jun 21, 2006 @ 17:45:35

As the CakePHP framework grows in popularity, more and more tutorials are show up for it, including this quick and handy one from Graham Bird. In it, he explains the use of "slugs" instead of IDs to make URLs simpler to use and remember.

In this tutorial you will learn how to use words rather than IDs in your Cake URLs. These words are known as "slugs" in Wordpress so I decided to call them slugs too.

Cake's normal URLs look like this: www.example.com/stories/read/123245221
and we are going to make them look like this: www.example.com/stories/read/sleepingbeauty

Thanks to the simplicity of the framework, the tutorial is pretty short, using one of CakePHP's "magic functions" to help cross-match the slug given with a table in the database with a slug/title relationship. There's not much code to it and he provides a demo

tagged: cakephp tutorial slugs id simple database cakephp tutorial slugs id simple database

Link:

Graham Bird's Blog:
Extra-pretty URLs with slugs
Jun 21, 2006 @ 17:45:35

As the CakePHP framework grows in popularity, more and more tutorials are show up for it, including this quick and handy one from Graham Bird. In it, he explains the use of "slugs" instead of IDs to make URLs simpler to use and remember.

In this tutorial you will learn how to use words rather than IDs in your Cake URLs. These words are known as "slugs" in Wordpress so I decided to call them slugs too.

Cake's normal URLs look like this: www.example.com/stories/read/123245221
and we are going to make them look like this: www.example.com/stories/read/sleepingbeauty

Thanks to the simplicity of the framework, the tutorial is pretty short, using one of CakePHP's "magic functions" to help cross-match the slug given with a table in the database with a slug/title relationship. There's not much code to it and he provides a demo

tagged: cakephp tutorial slugs id simple database cakephp tutorial slugs id simple database

Link:

VoucherTrader.co.uk Blog:
A Further Problem With PHP Session IDs and Google
Jan 12, 2006 @ 12:48:32

On vouchertrader.co.uk today, there's this look at some more issues that can be caused by session IDs with the indexing that Google performs.

While search for the VoucherTrader site in Google I noticed that the description for some pages was coming up as a PHP error about sessions. I actually thought I'd fixed this problem before by preventing PHP from creating sessions when the browsing user's user agent was the Googlebot. Unfortunately I was wrong...

Come to find out, he figured out that, at the time the GoogleBot was coming through, the PHP install wasn't making a session for it. For a fix, he threw in a check to ensure that the user, based on the HTTP_USER_AGENT value, would start the session correctly. The code is included in the post...

tagged: session ID google indexing session_start HTTP_USER_AGENT session ID google indexing session_start HTTP_USER_AGENT

Link:

VoucherTrader.co.uk Blog:
A Further Problem With PHP Session IDs and Google
Jan 12, 2006 @ 12:48:32

On vouchertrader.co.uk today, there's this look at some more issues that can be caused by session IDs with the indexing that Google performs.

While search for the VoucherTrader site in Google I noticed that the description for some pages was coming up as a PHP error about sessions. I actually thought I'd fixed this problem before by preventing PHP from creating sessions when the browsing user's user agent was the Googlebot. Unfortunately I was wrong...

Come to find out, he figured out that, at the time the GoogleBot was coming through, the PHP install wasn't making a session for it. For a fix, he threw in a check to ensure that the user, based on the HTTP_USER_AGENT value, would start the session correctly. The code is included in the post...

tagged: session ID google indexing session_start HTTP_USER_AGENT session ID google indexing session_start HTTP_USER_AGENT

Link:


Trending Topics: