Skip to content

Instantly share code, notes, and snippets.

@Blizzke
Blizzke / gist:c46f614640be10ecf2d3
Created July 16, 2015 09:55
Heroku split dependencies composer.json

Hello,

Our demo application running on heroku uses the default composer.json for our project. Unfortunately the project contains functionality that is optional in use for the user, but would be nice to be able to demo in the site.

So we're having a bit of a dilemma: Take for example our soap logging functionality. We would like to demo it, but including the extension as a dependency in the composer.json would force all our users to have it too, which is not what we want. We've added yii2-swiftmailer already as a dependency (which is also optional) to demonstrate the mail capabilities.

Is there another way to indicate to to Heroku that it should install the soap extension? Eg a require-heroku in the composer.json or some settings in a .heroku.yml? We would really like to avoid having to add another branch to maintain specifically for that purpose.

public function addBatchData($batchData, $compact = true)
{
$columns = ['entry_id', 'type', 'data'];
$rows = [];
foreach ($batchData as $type => $data) {
$rows[] = [$this->id, $type, [Helper::serialize($data, $compact), \PDO::PARAM_LOB]];
}
static::getDb()->createCommand()->batchInsert(AuditData::tableName(), $columns, $rows)->execute();
}
@Blizzke
Blizzke / ErrorHandlerTrait.php
Created June 29, 2015 13:41
Alternative to error catching before bootstrap
<?php
/**
* Error Handler allows errors to be logged to the audit_error table.
*/
namespace bedezign\yii2\audit\components\base;
use bedezign\yii2\audit\Audit;
use bedezign\yii2\audit\models\AuditError;
use Exception;
class ActiveRecord extends CActiveRecord
{
public static function model($sClassName = NULL)
{
if ($sClassName == NULL)
$sClassName = get_called_class();
$oModel = parent::model($sClassName);
$oModel->resetScope();
$oModel->setDbCriteria(new CDbCriteria($oModel->defaultScope()));
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title> - jsFiddle demo</title>
<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/foundation/5.2.1/css/foundation.min.css">
<script type='text/javascript' src="//ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script type='text/javascript' src="//cdnjs.cloudflare.com/ajax/libs/foundation/5.2.1/js/foundation/foundation.min.js"></script>
<script type='text/javascript' src="//cdnjs.cloudflare.com/ajax/libs/foundation/5.2.1/js/foundation/foundation.reveal.js"></script>
<script type='text/javascript'>//<![CDATA[