I want to merge multiple collections into one. I do have a solution, which is the following: This actually does work, but I run into problems in cases where some or all of the collections contain no objects. I get an error along the lines of call to merge() on non object. I actually tried to create an array o…
Tag: php
Passing $_POST/$_GET as a parameter to function
I came across an interesting piece of PHP code which has me a bit stumped as to why the author has chosen to do this. It got me thinking about why someone would want to pass $_POST as a variable and just not access it directly inside the function? The only benefit I could think of (and this was a
How to extract in a text file only the needed data and save it to csv using php
I was given a text file that contains more than a hundred of rows with 6 columns but the data that i need are on column 3 and 6 and save it to a csv file. The text file contains like this: By the way the text file came from a biometrics thumb print machine that records the following data
Execute Laravel/Symfony/Artisan Command in Background
I need to execute a Laravel long running process in the background for consuming the Twitter Streaming API. Effectively the php artisan CLI command I need to run is nohup php artisan startStreaming &…
PHP Mocking Final Class
I am attempting to mock a php final class but since it is declared final I keep receiving this error: PHPUnit_Framework_Exception: Class “DoctrineORMQuery” is declared “final” and cannot be mocked. Is there anyway to get around this final behavior just for my unit tests without introdu…
Pushing a sub array into the same array
I am trying to put content of one array into the same array. Here I have an array $mclass with values such as You can see I have room_id index with 1,3,5 value. Now, I want to explode the room_id and get duplicate of same array index data with change of room_id and push into the array. and finally delete
How to copy very large files from URL to server via PHP?
I use the following code to copy/download files from an external server (any server via a URL) to my hosted web server(Dreamhost shared hosting at default settings). However the function stops running at about once 2.5GB (sometimes 2.3GB and sometimes 2.7GB, etc) of the file has downloaded. This happens every…
PHP: “failed to open stream: Permission denied”
I am getting some interesting results on my server when i try to access any Directory or File via some Function.I have set all my file & directory permissions to 777 and have changed the content owner to Apache but i still get error messages.Code: move_uploaded_file($_FILES[‘file’][‘tmp_…
get uploaded file size in bytes in php
I am uploading a file which is an image. I want to get the size of that image every time in bytes only using PHP. I had done this by far $name=$_FILES[‘image’][‘name’]; if($name!=null) { $tmpDest=…
Working directly with libraries instead of bundles in Symfony2
How can I use a library directly inside an existing Symfony2 project. I am, for instance, trying to add the faker library. I installed it via composer but I don’t know how and where to put the code I need. According to documentation: What is a simple explanation of auto loader? How to use a library dire…