Amazon Elastic Transcoder API – Laravel 5

Here is simple example to create job  to transcode mp3 file to HLS-Audio for Amazon Elastic Transcoder .

include the package in composer https://github.com/aws/aws-sdk-php-laravel


<?php
namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use AWS;

class DexelUploadAudio extends Controller
{

public function __construct()
{

/* ... */
}

public function createjob()
{
$result = $ElasticTranscoder = AWS::createClient('ElasticTranscoder');
//pipeline id 1489836190416-r56a8n
//dd($ElasticTranscoder->listPipelines());
$ElasticTranscoder->createJob([
//pipeline id refer it in transcoder page eg : https://ap-southeast-2.console.aws.amazon.com/elastictranscoder/home?region=ap-southeast-2#pipelines:
'PipelineId'=>'XXXXXXXXX',
'Input' => [
//input file, which should exist in the bucket which is specified on pipeline
'Key' => 'sample.mp3',
'FrameRate' => 'auto',
'Resolution' => 'auto',
'AspectRatio' => 'auto',
'Interlaced' => 'auto',
'Container' => 'auto',
],
'Outputs'=>[
[
//output prefix file name
'Key' =>'string',
//System preset: HLS Audio - 64k

//Preset id refer it in transcoder page eg : https://ap-southeast-2.console.aws.amazon.com/elastictranscoder/home?region=ap-southeast-2#presets:

'PresetId'=>'XXXXXXXXXXX',
//seconds to split to file
'SegmentDuration'=>'10'
]
],
//output folder name
'OutputKeyPrefix'=>'string/'
]);
dd($result);
}
public function jobStatus($jobId)
 {
 $ElasticTranscoder = AWS::createClient('ElasticTranscoder');
 $result = $ElasticTranscoder->readJob(['Id' => $jobId]);
 dd($result);
 }
}

Crinsane/LaravelShoppingcart – Model not associating correctly or empty

I was having the exact same issue, using the most recent version 2.3.0.

Cart::add($product->uid, $product->name, $qty, $product->price)->associate('App\Models\Product');

In a foreach in my view, dd($product->model) returns null.

When try $this->cart->add($product->id, $product->title, 1, $product->price)->associate(‘App\Models\Product’);

works perfectly, primary key of product table has to placed in id. In my case I have id as primary key and uid as unique in product table.

Crinsane/LaravelShoppingcart content returns empty

More over I was struggling for a day on this. Then I found that because I put dd() in same request while cart add, the so session was not created for cart.

Try to first do the Cart::add() and no dd(). Then comment the Cart::add() and uncomment the dd()

Now you should see content, and a rowId. Now you should be able to delete it.

When you perform a dd() method, it will make the script die instantly, so the session is not written.

Install 2 version of PHP

Today I got again problem with PHP 7 and PHP 5 for mysql_connect which is deprecated in PHP 7.

So, this is the way to install both version , and use it when require .
Apache:

sudo a2dismod [php old] ;
sudo a2enmod [php new] ;
sudo service apache2 restart

to update the php cli to use the specific version
CLI:
sudo update-alternatives –set php /usr/bin/[php new]

Limit band with in Linux

To limit for interface

sudo apt-get install wondershaper

In terminal find out what is the name of the interface connected to your internet by using ifconfig. Could be eth0, eth1, eth2, etc... In my case is eth1. So, I would do this:

sudo wondershaper [interface] [dowload limit] [upload limit] 
eg : sudo wondershaper eth1 1024 256
If you want to reset that do this sudo wondershaper clear eth1

NOTE : This will limit entire speed of ysytem becasue , the limit applied to interface.

To limit the speed by application, we use below 
sudo apt-get install trickle
sudo trickle -d [download limit] -u [upload limit] [application name]
eg : sudo trickle -d 120 -u 32 firefox

NOTe : Without application name it will apply to over all system.