Skip to content

Instantly share code, notes, and snippets.

View vipulasa's full-sized avatar
🎯
Focusing

Vipula S Anandapiya vipulasa

🎯
Focusing
View GitHub Profile
@vipulasa
vipulasa / gist:0b857f43bd345bb71237cafe5ab79953
Created March 7, 2024 14:37
How to install ioncube on Laravel Forge
#!/bin/bash
wget https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz
tar zxvf ioncube_loaders_lin_x86-64.tar.gz
PHP_CONFD="/etc/php/7.4/fpm/conf.d"
PHP_VERSION=$(php -r "echo PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;")
PHP_EXT_DIR=$(php-config --extension-dir)
sudo cp "ioncube/ioncube_loader_lin_${PHP_VERSION}.so" $PHP_EXT_DIR
sudo echo "zend_extension = ${PHP_EXT_DIR}/ioncube_loader_lin_${PHP_VERSION}.so" > "${PHP_CONFD}/00-ioncube.ini"
PHP_CONFD="/etc/php/7.4/cli/conf.d"
PHP_VERSION=$(php -r "echo PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;")
@vipulasa
vipulasa / ModelTags.php
Last active November 1, 2023 18:39
Add global variable support for Laravel Eloquant Models with a Tag [Model:ID:attribute]
/**
* Transform a raw model value using mutators, casts, etc.
*
* @param string $key
* @param mixed $value
* @return mixed
*/
protected function transformModelValue($key, $value): mixed
{
// If the attribute has a get mutator, we will call that then return what
@vipulasa
vipulasa / Cors.php
Created July 24, 2018 05:28 — forked from drewjoh/Cors.php
Laravel CORS Middleware
<?php // /app/Http/Middleware/Cors.php
namespace App\Http\Middleware;
use Closure;
class Cors {
public function handle($request, Closure $next)
{
return $next($request)
@vipulasa
vipulasa / gist:3fb512a3df697274684688892189bd2a
Created April 18, 2017 20:12
How to enable Virtual box shared drives with Ubuntu
1. sudo apt-get install virtualbox-guest-dkms
2. sudo apt-get -y install dkms build-essential linux-headers-$(uname -r) virtualbox-guest-additions-iso
2. Create the following shell script to automatically mount
@vipulasa
vipulasa / visudo
Last active August 26, 2022 14:56
How to add www-data user to run GIT commands
In console with root user execute this command:
visudo
The "vi" editor will be opened. Add these lines:
Defaults:git !authenticate
git ALL=(www-data) ALL
In result the file (that is opened in "vi" editor by calling "visudo") should look like this:
# /etc/sudoers
@vipulasa
vipulasa / .htaccess
Created February 1, 2017 04:54
Laravel .htaccess file to be added to the server root when hosting the site on a shared server.
# Add this file to the document root of the web server so that it will redirect the request to the public folder
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
@vipulasa
vipulasa / clean-string.php
Created January 16, 2017 10:05
SEO friendlier version to clean strings - PHP
function hyphenize($string) {
$dict = array(
"I'm" => "I am",
"thier" => "their",
);
return strtolower(
preg_replace(
array( '#[\\s-]+#', '#[^A-Za-z0-9\. -]+#' ),
array( '-', '' ),
// the full cleanString() can be download from http://www.unexpectedit.com/php/php-clean-string-of-utf8-chars-convert-to-similar-ascii-char