Skip to content

Instantly share code, notes, and snippets.

View AydinHassan's full-sized avatar

Aydin Hassan AydinHassan

View GitHub Profile
<?php
require_once __DIR__ . '/app/code/local/Nivea/Mobile/Model/Device/Detect.php';
$mobile = new Nivea_Mobile_Model_Device_Detect();
$isMobile = $mobile->isMobile();
$currentUrl = $env = ($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'];
$scheme = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
if ($isMobile && $currentUrl == 'shop.nivea.co.uk') {
@AydinHassan
AydinHassan / dump-remote-db.sh
Last active August 29, 2015 13:57
Crude database ssh dump script
#!/bin/bash
if [ -z "$1" ]; then
echo "Please enter SSH host as first parameter. Eg aydin@192.168.0.1"
exit 1
fi
sshHost=$1
if [ -z "$2" ]; then
@AydinHassan
AydinHassan / gist:9450667
Created March 9, 2014 16:53
Phpunit stack trace
PHPUnit 3.7.32 by Sebastian Bergmann.
Configuration read from /var/www/jh-flexitime/module/JhTime/test/phpunit.xml
EF
Time: 67 ms, Memory: 6.00Mb
There was 1 error:
<?php
/**
* @author Marco Pivetta <ocramius@gmail.com>
*/
use Zend\ServiceManager\ServiceManager;
use Zend\Mvc\Service\ServiceManagerConfig;
use DoctrineORMModuleTest\Framework\TestCase;
use JhTimeTest\Util\ServiceManagerFactory;
use Zend\Loader\StandardAutoloader;
@AydinHassan
AydinHassan / gist:9939392
Last active August 29, 2015 13:58
ZF2 Unit Tests - Merge code - coverage
composer install --dev --prefer-source
mkdir -p build/coverage
cp tests/TestConfiguration.php.travis tests/TestConfiguration.php
ls -d tests/ZendTest/* | parallel --gnu --keep-order 'echo "Running {} tests"; ./vendor/bin/phpunit -c tests/phpunit.xml.dist --coverage-php build/coverage/coverage-{/.}.cov {};' || exit 1
#Generates error
php vendor/bin/phpcov.php --merge --clover build/logs/clover.xml --whitelist library build/coverage
aydin@ubuntu ~/zf2:master$ php vendor/bin/phpcov.php --merge --clover build/logs/clover.xml --whitelist library build/coverage
PHP Warning: require(ezc/Base/base.php): failed to open stream: No such file or directory in /home/aydin/Documents/zf2/vendor/sebastianbergmann/phpcov/src/autoload.php on line 45
@AydinHassan
AydinHassan / gist:9942903
Created April 2, 2014 20:51
Travis build script
for d in module/*/test
do
echo "Running $d tests"
fileName=$(echo $d | tr '/' '-')
vendor/bin/phpunit -c $d/phpunit.xml --coverage-php build/coverage/coverage-$fileName.cov $d
done
@AydinHassan
AydinHassan / gist:11206684
Created April 23, 2014 08:15
ZF2 module structure
.
├── config
│   └── autoload
├── module
│   ├── JhHub
│   │ ├── public
│   │ └── bower.json
│   ├── JhOvertime
│   │ ├── public
│   │ └── bower.json
@AydinHassan
AydinHassan / Module.php
Created May 8, 2014 12:50
Dynamically load ZF2 Module
//Module.php
namespace JhHub;
class Module implements
ConsoleBannerProviderInterface,
ConfigProviderInterface,
AutoloaderProviderInterface
{
@AydinHassan
AydinHassan / gist:7e2e9839cf9cb68931e8
Last active August 29, 2015 14:01
ZF2 Module Installer
I want the ability to be able to "install" modules which require installing.
If they have not been installed, then they should not be loaded.
Imagine there is one module in a ZF2 Skeleton App. Named "Hub".
It has an "install" cli route, which loops through all loaded modules.
If they implement "InstallableInterface" they will provide some install service.
The "install" command will run each of these
services "install" method.
One example (my use case) is that I need to loop thorugh each user and create a 'user_flex_settings' row for them.
@AydinHassan
AydinHassan / gist:33b62ec0feba2f80b590
Last active August 29, 2015 14:01
ZF2 console route with minus number as parameter
Not sure if this is an issue or expected:
I have the following console route:
return [
'console' => [
'router' => [
'routes' => [
'set-user-starting-balance' => [
'options' => [