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

Lorna Mitchell:
Handling Composer "lock file out of date" Warning
Jan 22, 2016 @ 15:48:23

Lorna Mitchell has a post on her site that wants to help you out when Composer reports a "lock file out of date" warning when you try to update your Composer dependencies. She provides three options to help resolve this issue.

Composer is dependency management for PHP, and it consists of two main files: [composer.json and composer.lock]. Crucially, the composer.lock also includes a hash of the current composer.json when it updates, so you can always tell if you've added a requirement to the composer.json file and forgotten to install it.

The post includes three different ways to correct the warning message:

  • Option one: upgrade all of the things
  • Option two: try to work out which composer.json change caused this
  • Option three: do nothing, safely

The first two options are preferable to the last one (essentially overriding the error) but it could be used in cases where you think Composer is just getting things wrong.

tagged: composer lock file outofdate warning option fix override

Link: http://www.lornajane.net/posts/2016/handling-composer-lock-file-out-of-date-warning

Mark Story's Blog:
New errors in PHP 5.4
Dec 30, 2011 @ 14:30:45

In this quick new post to his blog Mark Story talks about two new errors he ran across when upgrading his installation to PHP 5.4, both showing up under E_ALL.

I’ve been running the PHP5.4 RC builds for the last few months, and there are some interesting changes in the upcoming PHP release. On top of all the great new features coming in PHP5.4. After updating to PHP5.4-RC4, a few things that used to not trigger errors and silently do the wrong thing, now trigger notices or warnings.

The two he mentions deal with a new warning on illegal string offsets and the other about string offsets ("Notice: String offset cast occurred"). You can find out about more changes in the PHP 5.4 series in the various Changelogs for each Release Candidate and beta release.

tagged: new error update version warning notice offset string

Link:

Slawek Lukasiewicz's Blog:
PHP application diagnostics - Memtrack
Nov 08, 2011 @ 18:08:37

Slawek Lukasiewicz has posted about a handy tool that can be used to track memory consumption and performance in your PHP application - memtrack.

Application profiling can help us determine bottlenecks and possible problems during development. But sometimes we also need to diagnose problems in production environment. Frequent performance problems are connected with functions and methods using too much memory.

The tool allows you to set up thresholds for memory consumption and, if the scripts exceeds it, add warnings to your log files. He includes the simple instructions to install it (via PECL) and enable it in your php.ini. Some sample code to create a memory overvload is included to test it out. Configuration options let you set the limits and define functions to ignore if you know for sure there's trouble spots.

tagged: memtrack extension diagnostic limit warning

Link:

PHP.net:
5.3.7 upgrade warning
Aug 22, 2011 @ 17:32:48

In a quick note from the PHP.net site, they have a warning for those running PHP 5.3.7 (the most recent release) - there's a bug that's serious enough (with crypt) to where upgrades should probably wait until 5.3.8.

Due to unfortunate issues with 5.3.7 (see bug#55439) users should wait with upgrading until 5.3.8 will be released (expected in few days).

The issue causes the crypt() function to only return the (MD5-only) salt it was given instead of the correctly hashed string. If you need to replace this immediately, you can pull the latest from the snaps site (or binaries for Windows). Keep an eye out for PHP 5.3.8 in the near future.

tagged: version crypt salt md5 hash warning upgrade

Link:

Lorna Mitchell's Blog:
Declaring Static Methods in PHP
Dec 10, 2010 @ 14:40:45

Lorna Mitchell has a new post to her blog today talking about static methods and how to use them correctly in your code (as discovered accidentally in her own code).

I was confused recently to realise that I had accidentally called a static method in PHP dynamically from another part of my code; I expected PHP to output warnings when this is done. On closer inspection I discovered that: static functions can be called dynamically and dynamic functions generate an E_STRICT error if called statically.

She illustrates with some sample code that, when run with E_ALL and E_STRICT throws a warning from the strict side about calling a non-static method statically. She also talks about why it throws this warning for the non-static call on a static method. She also explains why, when a static method is called dynamically, no warning is thrown.

tagged: declaring static method warning strict

Link:

Misko Hevery's Blog:
Guide: Writing Testable Code
Jan 07, 2009 @ 16:29:39

In this slightly older (Nov 2008) but useful post to Misko's blog, he takes a look at a few common flaws that you should avoid in writing up your code (in any language really).

To keep our code at Google in the best possible shape we provided our software engineers with these constant reminders. Now, we are happy to share them with the world.

Here's the list of the flaws:

  • Flaw #1: Constructor does Real Work
  • Flaw #2: Digging into Collaborators
  • Flaw #3: Brittle Global State & Singletons
  • Flaw #4: Class Does Too Much

Each includes some warning signs to keep an eye out for to see if you and your code might be straying the wrong way.

tagged: testable guide hint flaw avoid warning sign

Link:

PHPFreaks.com:
Debugging: A Beginner's guide
Jun 10, 2008 @ 12:59:13

On PHPFreaks.com there's a new tutorial providing a beginner's guide to debugging in PHP (with the built in functionality PHP has, not external software).

Everyday the forums see probably hundreds of topics posted where the problem is a fairly simple error. [...] As a beginner, it can be difficult to find and solve these errors. By tackling each of these in turn, I hope to teach you some methods of finding and solving them.

They look at the different sorts of errors - syntax errors, fatal errors, warnings, notices - as well as some of the ones a bit harder to track down like database problems and logical errors.

tagged: debug beginner guide parse warning fatal error notice

Link:

Mindoop Blog:
SEO Warning : Zend framework and duplicate content
Nov 21, 2007 @ 13:54:00

On the Mindoop blog, there's a new post talking about some of the issues that the Zend Framework could cause with the SEO for your site - a simple reason, really.

Zend framework is becoming a first choice framework for a large percentage of PHP developers. It's native support for advanced URL routing makes implementing search engine optimized URLs a breeze. Or not?

Because of the reserved words for the controllers and the multiple ways to access the actions below it (his example is case_studies, case-studies and case)studies) make three different ways to get to the same content - a SEO no-no.

tagged: seo warning zendframework duplicate content seo warning zendframework duplicate content

Link:

Mindoop Blog:
SEO Warning : Zend framework and duplicate content
Nov 21, 2007 @ 13:54:00

On the Mindoop blog, there's a new post talking about some of the issues that the Zend Framework could cause with the SEO for your site - a simple reason, really.

Zend framework is becoming a first choice framework for a large percentage of PHP developers. It's native support for advanced URL routing makes implementing search engine optimized URLs a breeze. Or not?

Because of the reserved words for the controllers and the multiple ways to access the actions below it (his example is case_studies, case-studies and case)studies) make three different ways to get to the same content - a SEO no-no.

tagged: seo warning zendframework duplicate content seo warning zendframework duplicate content

Link:

The Bakery:
Clear the PHP4 warnings when working in eclipsePHP
Feb 20, 2007 @ 18:47:00

CakePHP users can find a quick hint from The Bakery today pointing out how to get ride of some of the warning messages when working with the framework in PHP4.

CakePHP - a great framework, but sometimes surprising to those who are used to programming with PHP 5. EclipsePHP spits out pages and pages of warnings when compiling towards a PHP 5 base, scaring new CakePHP converts.

The method involves performing a global search and replace on seven key strings to help them conform to the CakePHP standards. The warnings will "magically" disappear following.

tagged: eclipsephp warning php4 cakephp framework search replace eclipsephp warning php4 cakephp framework search replace

Link:


Trending Topics: