Skip to content

Instantly share code, notes, and snippets.

View abdullahbutt's full-sized avatar

Abdullah Butt abdullahbutt

  • Fulda, Deutschland
View GitHub Profile
@abdullahbutt
abdullahbutt / megento 2.3.x blank page issue solution
Last active July 29, 2019 08:51
megento 2.3.x blank page issue solution
This is Magento bug. Wrong paths to Windows are generated. The fixed fix is:
Magento 2.3.0
#/vendor/magento/framework/View/Element/Template/File/Validator.php:138
the string
$realPath = $this->fileDriver->getRealPath($path);
@abdullahbutt
abdullahbutt / generating random alphanumeric strings in php
Created June 19, 2019 08:40
generating random alphanumeric strings in php
<?php
// https://code.tutsplus.com/tutorials/generate-random-alphanumeric-strings-in-php--cms-32132
//$permitted_chars = '0123456789abcdefghijklmnopqrstuvwxyz';
$permitted_chars = '0123456789abcdefghijklmnopqrstuvwxyz!@#%';
// Output: 54esmdr0qf
$password = substr(str_shuffle($permitted_chars), 0, 8);
echo $password;
@abdullahbutt
abdullahbutt / failed loading cafile stream
Created June 11, 2019 11:09
failed loading cafile stream: curl-ca-bundle.crt
Error / Notice / Issue:
failed loading cafile stream: `C:\xampp\apache\bin\curl-ca-bundle.crt'
Issue
[curl]
; A default value for the CURLOPT_CAINFO option. This is required to be an
; absolute path.
;curl.cainfo=
@abdullahbutt
abdullahbutt / php curl upload file.php
Last active May 2, 2019 10:20
php curl to upload file
<?php
use Illuminate\Support\Facades\Log;
$imageUrl = $linPost->pic_1; // This is a complete URL Path
$pos = strrpos($imageUrl, '/');
$imageName = $pos === false ? $imageUrl : substr($imageUrl, $pos + 1);
$extension = substr(strrchr($imageUrl,'.'),1);
if($extension == 'mp4' || $extension == 'MP4' || $extension == 'mov' || $extension == 'MOV')
{
$path_image_save = public_path('assets/imagegallery/video_upload/' . $imageName);
@abdullahbutt
abdullahbutt / api call file_get_contents with headers.php
Last active March 15, 2019 11:26
api call file_get_contents with headers
<?php
$arrContextOptions = [
"ssl"=> [
"verify_peer"=>false,
"verify_peer_name"=>false,
],
"http" => [
"method" => "GET",
@abdullahbutt
abdullahbutt / Remove Whitespace and line breaks from String using PHP
Created March 12, 2019 13:15
Remove Whitespace and line breaks from String using PHP
https://arjunphp.com/remove-whitespace-line-breaks-string-php/
Remove Whitespace and line breaks from String using PHP
In PHP we have in-build functions to replace white-space from the start and end of the string these are trim, ltrim and rtrim. These functions are incapable of removing line breaks from the target string, a simple search and replace will not get line breaks.
trim() function will remove white-space from start and end of the given string.
rtrim() function will remove white-space from end of the given string.
ltrim() function will remove white-space from the begging of the string.
@abdullahbutt
abdullahbutt / Handler.php
Created January 16, 2019 06:53
laravel api validation response 422 solution
<?php
//location in Laravel Project: project_root\app\Exceptions\Handler.php
// I have modified the "render" method on line 51 (on line 48 in actual file in Laravel)
namespace App\Exceptions;
use Exception;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Validation\ValidationException;
@abdullahbutt
abdullahbutt / Magento Allowed memory size exhausted error
Last active October 24, 2018 06:09
Magento Allowed memory size exhausted error
First ONLY run below 2 commands:
php bin/magento cache:flush
php bin/magento cache:clean
Issue should be resolved.
If isue persists, try below commands:
php bin/magento setup:upgrade
@abdullahbutt
abdullahbutt / Magento wamp 500 Internal Server Error
Created October 24, 2018 06:07
Magento wamp 500 Internal Server Error
Following error you have given in your post's comment should lead you to the solution after a little search.
The problem is Magento's .htaccess file consists <IfVersion> command.
In order to use this feature mod_version module should have enabled on your Apache web server. Otherwise it will give 500 error.
In Wamp it is disabled by default.
@abdullahbutt
abdullahbutt / php generate random string up to x length
Created September 30, 2018 18:47
php generate random string up to x length
function generateRandomString($length = 10) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}