PHP

Install PHP 5.3 on Ubuntu 17.10

I know, I know, I know, I know! I need to update my code! If I haven’t said it already, I know! But… I don’t have time to updated hundreds upon hundreds of lines of code, so I’m taking the easy way out.

I found the steps to do it here: http://sandeep-bisht.blogspot.com/2017/08/phpbrew-install-php-53-in-ubuntu-1604.html

The system I’m installing from is a fresh install of Ubuntu 17.10, so I’m assuming NOTHING has been pre-installed with these instructions.

Install PHP

sudo apt install php -y

Download and configure phpbrew

sudo apt install -y curl
curl -L -O https://github.com/phpbrew/phpbrew/raw/master/phpbrew
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   130  100   130    0     0     43      0  0:00:03  0:00:03 --:--:--    42
100 1792k  100 1792k    0     0   224k      0  0:00:08  0:00:08 --:--:--  460k
chmod +x phpbrew
sudo mv phpbrew /usr/bin/phpbrew
sudo nano /root/.bashrc
# Added this line to install PHP 5.3 per instructions found here:
# http://sandeep-bisht.blogspot.com/2017/08/phpbrew-install-php-53-in-ubuntu-1604.html
[[ -e ~/.phpbrew/bashrc ]] && source ~/.phpbrew/bashrc

Initialize phpbrew

phpbrew init
Using root: /home/thomasr/.phpbrew
Initialization successfully finished!
<=====================================================>
Phpbrew environment is initialized, required directories are created under

    /home/thomasr/.phpbrew

Paste the following line(s) to the end of your ~/.bashrc and start a
new shell, phpbrew should be up and fully functional from there:

    source /home/thomasr/.phpbrew/bashrc

To enable PHP version info in your shell prompt, please set PHPBREW_SET_PROMPT=1
in your `~/.bashrc` before you source `~/.phpbrew/bashrc`

    export PHPBREW_SET_PROMPT=1

To enable .phpbrewrc file searching, please export the following variable:

    export PHPBREW_RC_ENABLE=1


For further instructions, simply run `phpbrew` to see the help message.

Enjoy phpbrew at $HOME!!

<=====================================================>

Update for old versions and display

phpbrew update --old
===> Fetching release list...
Downloading https://secure.php.net/releases/index.php?json&version=7&max=1000 via php stream
Downloading https://secure.php.net/releases/index.php?json&version=5&max=1000 via php stream
7.2: 4 releases
7.1: 16 releases
7.0: 29 releases
5.6: 35 releases
5.5: 39 releases
5.4: 46 releases
5.3: 30 releases
5.2: 17 releases
5.1: 7 releases
5.0: 6 releases
===> Done

phpbrew known

By admin on March 2, 2018 | Debian / Ubuntu, Linux, PHP

JPGraph.PHP Functions

Graph Class

require_once ('jpgraph/jpgraph.php');

Required commands:

$graph = new Graph($width, $height);
$graph->SetScale('textlin'); //starts at 1
$graph->SetScale('intlin'); //starts at 0
//secondary Scale
$graph->SetY2Scale("lin");

Display:

$graph->SetShadow();
$graph->Stroke();

Margins:

$graph->img->SetMargin($left,$right,$top,$bottom);

Title:

$graph->title->Set($title);
$graph->subtitle->Set($subtitle);

Axis

Colors

$graph->xaxis->SetColor("blue");
$graph->yaxis->SetColor("green");
$graph->y2axis->SetColor("orange");

Intervals (Default 1,2,3,4)

$graph->xaxis->SetTextTickInterval(2); // 1,3,5,7

Margins:
Leave 20px above max y limit

$graph->yaxis->scale->SetGrace(20);

Titles (Labels)

$graph->xaxis->SetFont(FF_FONT,FS_BOLD [,$fontSize]); //make label bold
$graph->xaxis->title->Set($xTitle);
$graph->yaxis->title->Set($yTitle);

Title Color

$graph->xaxis->SetColor('blue');
$graph->yaxis->SetColor('red');

Plotting Data

Line Graph

Required:

require_once ('jpgraph/jpgraph_line.php');

$dataset1=array($da1,$da2,$da3); //2,4,6
$dataset2=array($db1,$db2,$db3); //30,45,75

$line1 = new LinePlot($dataset1);
$graph->Add($line1);
$graph->AddY2($line2);

Line Weight:

$graph->img->SetAntiAliasing(FALSE); //required due to bug
$line1->SetWeight(3);

Bar Graph

Required:

require_once ('jpgraph/jpgraph_bar.php');

$dataset1=array($da1,$da2,$da3); //2,4,6
$dataset2=array($db1,$db2,$db3); //30,45,75

$line1 = new LinePlot($dataset1);
$graph->Add($line1);
$graph->AddY2($line2);

Width:

$bplot->SetWidth(0.7);

Legend:

$line1->SetLegend($dataLabel);

Text

$txt=new Text('This is a text');
$txt->SetPos(0,20);
$txt->SetColor('darkred');
$txt->SetFont(FF_FONT2,FS_BOLD);
$graph->AddText($txt);

Bugs!

Notice!!
There is a bug in the examples that causes multiple require_once(‘jpgraph/whatever.php’); to fail.

Example:

require_once('jpgraph/jpgraph.php');
require_once('jpgraph/jpgraph_line.php');
require_once('jpgraph/jpgraph_bar.php');

The above example causes the following error:

PHP Warning:  include_once(): Failed opening 'jpgraph/jpgraph_bar.php' for inclusion ...

The Workaround

This error is resolved by changing the include path to ‘../’

Example

require_once('../jpgraph.php');
require_once('../jpgraph_line.php');
require_once('../jpgraph_bar.php');

Examples

21 2 Bar sets
23 Stacked bars
25 Adding text
26 Pie

y2synch.php – Sycronised Y and Y2 scales (deg F && deg C)

By admin on December 4, 2014 | PHP | A comment?