Category Archives: Php

Laravel Homestead Database Export and Import

SSH into your homestead box and run the two commands to export or import your databases via the Aliases below. or

Hex2Bin function

One host I know of refuses to upgrade anything and this is a hex2bin function in case you get :    

Load custom php.ini with CRON job

Live and learn. I didn’t realize that when a cron job runs, it does not load the site php.ini file, but by adding a custom directive, we can tell the the php cron job to load the file. The error I was receiving is below even though I had allow_url_fopen enabled:
Warning: simplexml_load_file(): http:// wrapper is disabled in the server configuration by allow_url_fopen=0 in /home/username/script.php on line 12
Adding the custom directive resolved the issue and hopefully will for you too.

Save remote image to server with PHP

I was working on a project where I was using an API to connect to Amazon to pull book details via ISBN. I needed to store the remote images on my server to be associated with the product that was being created and I put together these few lines of code to do so. It obviously will need to be reworked for your own needs, but the logic is below.

If you wanted to use directories on server you could (remove the last line above and) do something like

This WordPress code tag BS is pissing me off and I will be finding a plugin to allow all this to be copied and pasted easily 🙂