Skip to content

Instantly share code, notes, and snippets.

View zaherg's full-sized avatar
🎯
Focusing

Zaher Ghaibeh zaherg

🎯
Focusing
View GitHub Profile
{
"jsdocs_align_tags": "no",
"jsdocs_param_description": false,
"jsdocs_return_description": false,
"jsdocs_spacer_between_sections": true
}

My Validation Base Class

I was asked how I deal with validation / create and update validation rulesets. Well here is one method I have used. Don't be afraid to build on top of what the framework has already given you. In my projects I use a base class for almost anything. You never know when you want your classes to inherit some common functionality. My BaseValidator actually has some pretty useful methods and properties in it.

<?php

namespace FooProject\Internal\Validators;

use FooProject\Internal\Sanitizers\BaseSanitizer;
@zaherg
zaherg / swap.md
Created January 25, 2014 07:31
create a swap on VPS
sudo dd if=/dev/zero of=/swapfile bs=1024 count=512k && sudo mkswap /swapfile && sudo swapon /swapfile

edit fstab

sudo nano /etc/fstab 

add to fstab

/swapfile       none    swap    sw      0       0 
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"laravel/framework": "4.1.*",
"way/generators": "dev-master",
"cartalyst/sentry": "2.0.*",
"jasonlewis/basset": "dev-master",
@zaherg
zaherg / List.md
Created January 28, 2014 11:16 — forked from msurguy/List.md

My projects (tutorials are on my blog at http://maxoffsky.com):

#!/bin/bash
echo "Generating an SSL private key to sign your certificate..."
openssl genrsa -des3 -out myssl.key 1024
echo "Generating a Certificate Signing Request..."
openssl req -new -key myssl.key -out myssl.csr
echo "Removing passphrase from key (for nginx)..."
cp myssl.key myssl.key.org
openssl rsa -in myssl.key.org -out myssl.key
@zaherg
zaherg / upload.php
Created February 25, 2014 07:47 — forked from msurguy/upload.php
ini_set("memory_limit","200M");
if( !empty($_SERVER['HTTP_ORIGIN']) ){
// Enable CORS
header('Access-Control-Allow-Origin: ' . $_SERVER['HTTP_ORIGIN']);
header('Access-Control-Allow-Methods: POST, GET, OPTIONS');
header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Range, Content-Disposition, Content-Type');
}
if( $_SERVER['REQUEST_METHOD'] == 'OPTIONS' ){
<?php
use Illuminate\Support\Contracts\ArrayableInterface;
use Illuminate\Support\Contracts\JsonableInterface;
class Excel implements ArrayableInterface, JsonableInterface{
protected $objPHPExcel;
public function __construct($file){
if($file instanceof \SplFileInfo){
$filename = $file->getRealPath();

Symfony Security Checker in Laravel

Artisan command for Sensiolabs Security Checker

Require this project in your composer.json file

"sensiolabs/security-checker": "dev-master"

Add the following line to app/start/artisan.php:

<?php namespace Initr\Services;
use Illuminate\Validation\Factory as LaravelValidator;
abstract class Validator
{
protected $validator;
protected $data = array();