php preg_replace problem with large files/strings – fails silently

Martin Zeller php 0 Comments

If you have a problem with preg_replace or other PCRE functions in php, because they fail  silently, without error message or other feedback, especially with large strings, then have a look at this php.ini setting: pcre.backtrack_limit For example, modify the value in your php script: Just increase the default value of 1.000.000. Maybe you have to increase the value for memory_limit …

zf2 – translatePlural example with Poedit

Martin Zeller php, zf2 1 Comment

I’d like to explain how to use the translatePlural method along with the Zend Framework 2. (I’m assuming that you have been configured Poedit and the Zend Framework so that it works with the normal translate method) The use of translatePlural is actually quite simple. Let us first look at the normal translate method: After parsing your code files with …

Subdomain based mobile versions in zf2 projects

Martin Zeller php, zf2 0 Comments

A few weeks ago it was my job to extend an existing Zend Framework 2 project with a mobile version. The orderer wanted when calling mobile.example.com/path1 a for mobile clients optimized version of www.example.com/path1 should be delivered. Some mobile versions of pages should have only a changed layout, while others should provide additional content. These requirements (for requests with the …

zf2, doctrine module and expressions (like ‚IS NOT NULL‘)

Martin Zeller doctrine, php, zf2 0 Comments

Currently I am working on a migration of a zend framework 1 project to zf2 (zend framework 2). Furthermore I want to introduce Doctrine to the project. There are some useful articles about installing and using the zf2 doctrine module. After some hours I found out how to use modules and Doctrine in zf2. Sometimes you will have code like …

Pdf thumbnails / Pdf to jpg

Martin Zeller php 2 Comments

Do you want to create thumbnails for pdf files with PHP (or C#)? You can simply do this with ghostscript. Here’s the php way (it is very easy to convert this code to C#): First install ghostscript on your server. Download: http://ghostscript.com/releases/ Then write your code: This code will generate a jpg file with the content of the first page …

Zend_Captcha, an example without Zend_Form

Martin Zeller php 2 Comments

Here is your example how to implement Zend_Captcha_Image without using Zend_Form. In your action method: In the corresponding view render the captcha and add a hidden field with the captcha id: Validating the input of the user after postback: Good luck! PS: If you want to use your Zend_Captcha WITH Zend_Form, this blog post may help you: Zend_Captcha with Zend_Form

PHP – Delete files by pattern

Martin Zeller php 1 Comment

If you want to delete files by pattern (e.g. „*.txt“) in a directory, you can do this with the php function glob! With this method you can also delete all files of a directory – with pattern *.*