Skip to content

Instantly share code, notes, and snippets.

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 Sep 19, 2012
ZF2 Service Locator caller
View zf2slcaller
In Controller : $this->getServiceLocator()
In Controller Plugin : $this->getController()->getServiceLocator()
View formselectinzf2
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 Oct 31, 2012
Install pecl install uploadprogress
View gist:3985339
CFLAGS="-arch i386" ./pecl install uploadprogress (this 'forces' a 32 bit install of the extension)
@samsonasik
samsonasik / gist:3988701
Created Oct 31, 2012
Send HTML Mail Using ZF2
View gist:3988701
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 Oct 31, 2012
Set Global Read-only false in Mysql
View gist:3988822
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 Nov 29, 2012
set #zf2 in shared hosting ( .htaccess )
View gist:4171219
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
View gist:4344029
Group -> Order -> Limit
View Sort associative array
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 Dec 14, 2015 — forked from robertbasic/gist:5047567
Unit Test select Join Zend\Db
View zenddbselectjoinunittest
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 Dec 14, 2015
session_start() conflict for ZF2 and your other App with session_start()
View 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();