Skip to content

Instantly share code, notes, and snippets.

View Sharifur's full-sized avatar
🎯
Focusing

Sharifur Rahman Sharifur

🎯
Focusing
View GitHub Profile
@Sharifur
Sharifur / wp-custom-breadcrumb.php
Created December 28, 2018 17:36
WordPress breadcrumb , WordPress custom breadcrumb, breadcrumb, breadcrumb trail
<?php
/**
* Zixer Custom Breadcrumb
* @since 1.0.0
*/
if (!function_exists('Zixer_Breadcrumb')) {
function Zixer_Breadcrumb(){
$frontend = Zixer('frontend');
// Set variables for later use
@Sharifur
Sharifur / queue-work-in-shared-hosting.php
Created July 31, 2023 17:00
how to run laravel queue:work command without memory leak in shared hosting
//add this code in app/console/kernel.php file insider schedule method
$schedule->command('queue:work --timeout=60 --tries=1 --once')
->everyMinute()
->withoutOverlapping()
->sendOutputTo(storage_path() . '/logs/queue-jobs.log');
@Sharifur
Sharifur / laravel-smtp-issue-fix.php
Last active June 8, 2023 15:29
laravel smtp setup showing error
'smtp' => [
'transport' => 'smtp',
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'timeout' => null,
'stream' => [
'ssl' => [
@Sharifur
Sharifur / InitializeTenancyByDomainCustomisedMiddleware.php
Created April 13, 2023 15:00
fix www. count as subdomain in tenancyforlaravel package
<?php
declare(strict_types=1);
namespace App\Http\Middleware\Tenant;
use Closure;
use Illuminate\Http\Request;
use Stancl\Tenancy\Contracts\Tenant;
use Stancl\Tenancy\Exceptions\TenantCouldNotBeIdentifiedByRequestDataException;
use Stancl\Tenancy\Middleware\IdentificationMiddleware;
@Sharifur
Sharifur / .htaccess
Created April 1, 2023 02:43
force ssl for laravel using htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
#extra start
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
//js function to change iframe markup into a shortcode
function iFrameFilterInSummernote(contents){
let rawContents = contents;
let matches = rawContents.match(/<iframe(.+)<\/iframe>/);
let ifamemarkup = Array.isArray(matches) ? matches[0] : '';
let srcMatches = ifamemarkup.match(/src="(.*?)"/);
let ifameSrc = Array.isArray(srcMatches) ? srcMatches[0] : '';
return rawContents.replace(/<iframe(.+)<\/iframe>/, '{iframe} {vsrc}="'+ifameSrc.replace('src="','')+'{/iframe}');
@Sharifur
Sharifur / .htaccess
Created December 10, 2022 07:18
showing unauthenticated in api
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^index\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]
@Sharifur
Sharifur / Session.php
Created April 27, 2018 06:26
laravel session cheatsheet
Session::get('key');
Session::get('key', 'default');
Session::get('key', function(){ return 'default'; });
Session::put('key', 'value');
Session::all();
Session::has('key');
Session::forget('key');
Session::flush();
Session::regenerate();
Session::flash('key', 'value');
@Sharifur
Sharifur / cache.php
Created April 27, 2018 06:35
laravel cache cheatsheet
Cache::put('key', 'value', $minutes);
Cache::add('key', 'value', $minutes);
Cache::forever('key', 'value');
Cache::remember('key', $minutes, function(){ return 'value' });
Cache::rememberForever('key', function(){ return 'value' });
Cache::forget('key');
Cache::has('key');
Cache::get('key');
Cache::get('key', 'default');
Cache::get('key', function(){ return 'default'; });
@Sharifur
Sharifur / Form.php
Created April 27, 2018 06:31
laravel form cheatsheet
Form::open(array('url' => 'foo/bar', 'method' => 'PUT'));
Form::open(array('route' => 'foo.bar'));
Form::open(array('route' => array('foo.bar', $parameter)));
Form::open(array('action' => 'FooController@method'));
Form::open(array('action' => array('FooController@method', $parameter)));
Form::open(array('url' => 'foo/bar', 'files' => true));
Form::close();
Form::token();
Form::model($foo, array('route' => array('foo.bar', $foo->bar)));