Skip to content

Instantly share code, notes, and snippets.

View samsonasik's full-sized avatar
🔥
I am doing very fast fix 🚀, sponsor me 💖 https://github.com/sponsors/samsonasik

Abdul Malik Ikhsan samsonasik

🔥
I am doing very fast fix 🚀, sponsor me 💖 https://github.com/sponsors/samsonasik
View GitHub Profile
@samsonasik
samsonasik / zf2slcaller
Created September 19, 2012 05:22
ZF2 Service Locator caller
In Controller : $this->getServiceLocator()
In Controller Plugin : $this->getController()->getServiceLocator()
@samsonasik
samsonasik / formselectinzf2
Created September 20, 2012 04:29
Form Select in ZF2
namespace SampleModule\Form;
use Zend\Form\Form;
class SampleForm extends Form
{
public function __construct($name = null)
{
parent::__construct('Sample Form');
@samsonasik
samsonasik / gist:3985339
Created October 31, 2012 06:19
Install pecl install uploadprogress
CFLAGS="-arch i386" ./pecl install uploadprogress (this 'forces' a 32 bit install of the extension)
@samsonasik
samsonasik / gist:3988701
Created October 31, 2012 17:57
Send HTML Mail Using ZF2
use Zend\Mail\Message;
use Zend\Mail\Transport\Smtp as SmtpTransport;
use Zend\Mime\Message as MimeMessage;
use Zend\Mime\Part as MimePart;
use Zend\Mail\Transport\SmtpOptions;
//////////
$message = new Message();
@samsonasik
samsonasik / gist:3988822
Created October 31, 2012 18:18
Set Global Read-only false in Mysql
Directory my mac :
/usr/local/mysql-5.5.21-osx10.5-x86_64/data
grant all on *.* to 'root'@'%'
mysql> set GLOBAL read_only = false;
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH TABLES WITH READ LOCK;
Query OK, 0 rows affected (0.07 sec)
@samsonasik
samsonasik / gist:4171219
Created November 29, 2012 19:20
set #zf2 in shared hosting ( .htaccess )
RewriteCond %{HTTP_HOST} ^yourdomain.com$ [NC,OR]
RewriteCond %{REQUEST_URI} !yourapp/public
RewriteRule (.*) /yourapp/public/$1 [L]
place it at your public_html (shared hosting 'root' directory ).
if you call http://yourdomain.com so you will point out to public_html/yourapp/public/index.php
@samsonasik
samsonasik / gist:4344029
Created December 20, 2012 09:10
order Query
Group -> Order -> Limit
function sortingAssoc($array, $sortby = "id",$sortir="asc")
{
$temp = array();
foreach($array as $key=>$row)
{
$temp[$key] = $row[$sortby];
}
if ($sortir=="asc") sort($temp); else rsort($temp);
@samsonasik
samsonasik / zenddbselectjoinunittest
Last active December 14, 2015 07:09 — forked from robertbasic/gist:5047567
Unit Test select Join Zend\Db
assume, i have a method in AlbumTable class like the following :
<?php
/////////
public function fetchAll()
{
$sqlSelect = $this->tableGateway->getSql()
->select()->columns(array('artist', 'title', 'id'))
->join('track', 'track.album_id = album.id', array(), 'left');
return $this->tableGateway->select($sqlSelect);
@samsonasik
samsonasik / session_start
Last active December 14, 2015 08:08
session_start() conflict for ZF2 and your other App with session_start()
<?php
chdir('/Users/abdulmalikikhsan/www/YOURZF2APP');
require 'init_autoloader.php';
Zend\Mvc\Application::init(require 'config/application.config.php');
chdir(__DIR__);
session_start();