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 / 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 / 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 / .htaccess
Created September 29, 2022 05:45
code for clear cache using htaccess
#Turns off the expires headers for Apache
<IfModule mod_expires.c>
ExpiresActive Off
</IfModule>
# Disable Caching
<IfModule mod_headers.c>
Header set Cache-Control "no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires 0
@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 / demo-middleware.php
Last active July 15, 2022 04:26
block post and put request in laravel using middleware
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Str;
class Demo
{
/**
$(document).on('input','#getquoteform textarea[name="assignment"]',function(){
let LongText = $(this).val();
$(this).val(LongText.replace(/[^a-zA-Z ]/g,''))
});
@Sharifur
Sharifur / canonical-url-generate-for-laravel.php
Created May 8, 2022 03:53
canonical url generate for laravel
function canonical_url()
{
if (\Illuminate\Support\Str::startsWith($current = url()->current(), 'https://www')) {
return str_replace('https://www.', 'https://', $current);
}
return str_replace('https://', 'https://www.', $current);
}