Running out of memory on Laravel 4 update

PECL out of memory with Composer and LaravelLaravel is great framework and I quite enjoy how it’s structured and how it works. In version 4 it was migrated from bundles to using Composer for dependency injection which is great and fits well in my daily routine on building apps also follows standards promoted by the PHP community in general.

In my application I was planning to add MongoDB support as first I’d like to improve the performance and second my data structure is perfect for this purpose, furthermore I want to improve my NoSQL skillset.

In this article I’ll describe the steps that I followed on installing the MongoDB provider, the problems that I’ve faced and final solutions and small tricks I used to make all work. Read more ›

Posted in BASH, Laravel, MongoDB, PHP, Unix Tagged with: , , , , ,

Pass parameters to Bash Alias command

pass console command parameters to bash alias command- like hammer bashes a nailI use BASH aliases extensively throughout my DEV environments and it saves me a lot of time. One specific I use is “cdv” that’s shorthand for CD to VirtualHosts which in most cases could be as simple as /var/www or in some cases could be very long path, especially on shared DEV environments like /var/www/dev/vhosts/mylongusername. Read more ›

Posted in BASH, Unix Tagged with: , , , , ,

Magento :: Export all customers and emails from orders

Magento export customer emails from ordersMagento export

Every now and then I am asked by different clients if I can export specific customer data, most often people need emails of their customers to use for newsletters or other types of marketing campaigns. There are two different ways to approach the problem either get all orders and get the customer email or any other related details that might be needed or you can use the customer collection which will give you all unique records for customers.

Setup magento API access

Read more ›

Posted in CMS, Magento, PHP Tagged with: , , , ,

Custom error handler for Laravel 4

Custom error handler for Laravel 4

Custom error handler for Laravel

I build API service for a mobile application and I faced a problem with the error reporting with Laravel.

Laravel is awesome framework and is great for RESTful application or building API that’s why it’s my first choice.

But I had one problem, my API should produce only JSON and my application can consume only JSON. So HTML error pages are pointless and needless for me. I had a specific case where a PHP error was causing problems but I also wanted to handle all PHP and display them appropriately for my app. Here is the solution: Read more ›

Posted in Laravel, PHP Tagged with: , , , ,

Consistent dates in PHP?

Consistent dates in PHP?

Consistent dates in PHP

It’s really interesting how small changes in core PHP functionality could break whole website and take hours to find the cause of the bug.

I am building website which takes some use of dates, stored in MySQL database as Date format for simplicity

Those dates are optional fields in my application and sometimes they have Zero Date format: ‘0000-00-00‘ which works perfectly on my development environment. Locally I am using PHP 5.3.4 not latest but allows me to spot any backward compatibility issues and probably it’s more laziness for not upgrading than any other sophisticated reason. Anyhow on production I run PHP 5.3.24 and so far everything has been just OK, running smoothly with no issues.
Read more ›

Posted in PHP Tagged with: , , ,

Install PHP mcrypt on UNIX server

Install PHP mcrypt linuxIn this quick tip I’ll show you how to install the PHP extensionmcrypt. This is needed for Magento to run properly otherwise you’ll get an error like:

Fatal error: Call to undefined function mcrypt_create_iv() in lib/Varien/Crypt/Mcrypt.php on line 64

Read more ›

Posted in Apache, CentOS, PHP, Servers, Small Tips Tagged with: ,

SQL: Remove HTML with procidure

Clean dirty html with sqlI had a problem with client’s data that was saved as HTML in the database and I needed it in plain format. Many would say this is very inefficient way of doing it but sometimes desperate time call for desperate measures. And here is my solution to the problem: Read more ›

Posted in Small Tips, SQL Tagged with: , ,

How to Move Magento to a New Server or Domain

Clone magento another hosting domainMagento is one of the fastest growing eCommerce platforms on the internet and with its recent acquisition by eBay it promises to stay on the lead and keep growing with even faster pace than before.  It’s been choice for a platform for many of my clients and recently I had to do some development work on one of the websites. The shop was running Magento 1.7 and was on a dedicated CentOS server.

Move Magento to different domain/subdomain

Read more ›

Posted in CMS, Magento, PHP Tagged with: , ,

Magento: How to reset admin pssword

Reset magento admin password with SQLIf you forget your admin password for Magento and you can’t remember the email or just want quick fix you can use one line of SQL to sort that issue out.

UPDATE admin_user SET password=CONCAT(MD5('qXpassword'), ':qX') WHERE username='admin';

All you have to do is replace the “password” with your required one and run the query.

Posted in Magento, Small Tips, SQL Tagged with: , ,

Serve main domain from subdirectory with .htaccess

Point root domain to s subfolder with .htaccessIf you are running your site on a shared hosting and you have multiple domain installed as subdirectories the things could go out of hand really fast. In my specific case I have multiple installs of different CMS and one main domain running from “root” directory. What I wanted was to be able to run all of my domain in separate sub folders. Here is the solution:

RewriteEngine on
# Part 1
RewriteCond %{HTTP_HOST} ^(www.)?$ [NC]
RewriteCond %{REQUEST_URI} !^/topdomain/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /topdomain/$1
# Part 2
RewriteCond %{HTTP_HOST} ^(www.)?$ [NC]
RewriteRule ^(/)?$ topdomain/index.php [L]

In first part I detect the domain, check if the doesn’t match our subdirectory, make sure that the URL doesn’t match any existing file or directory and last serve whole request from our subdirectory passing all other request parameters that may come with the original URL.

The second part serves any request to our top level domain that has no parameters to the index files in our designated sub directory this is needed because that rule would be skipped in first conditions because our root is existing directory.

So just replace the domain and the subdirectories and you are ready to go.

Posted in Apache, Servers, Small Tips Tagged with: , ,



I believe a leaf of grass is no less than the journey-work of the stars. — Walt Whitman