Skip to content

Commit 7107970

Browse files
committed
Fallback to PEAR-style require if autoload not present
1 parent 060450d commit 7107970

9 files changed

Lines changed: 64 additions & 9 deletions

File tree

tests/gradients.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@
2727
* @link http://pear.php.net/package/Image_Canvas
2828
*/
2929

30-
require_once 'vendor/autoload.php';
30+
if (file_exists('vendor/autoload.php')) {
31+
// use composer if available
32+
require_once 'vendor/autoload.php';
33+
} else {
34+
// otherwise rely on classic PEAR include_path
35+
require_once 'Image/Canvas.php';
36+
}
3137

3238
$canvas =& Image_Canvas::factory(
3339
'png',

tests/imagemap.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,14 @@
2727
* @link http://pear.php.net/package/Image_Canvas
2828
*/
2929

30-
require_once 'vendor/autoload.php';
30+
31+
if (file_exists('vendor/autoload.php')) {
32+
// use composer if available
33+
require_once 'vendor/autoload.php';
34+
} else {
35+
// otherwise rely on classic PEAR include_path
36+
require_once 'Image/Canvas.php';
37+
}
3138

3239
$canvas =& Image_Canvas::factory(
3340
'png',

tests/jpg.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@
3030
// SPECIFY HERE WHERE A TRUETYPE FONT CAN BE FOUND
3131
$testFont = 'c:/windows/fonts/Arial.ttf';
3232

33-
require_once 'vendor/autoload.php';
33+
if (file_exists('vendor/autoload.php')) {
34+
// use composer if available
35+
require_once 'vendor/autoload.php';
36+
} else {
37+
// otherwise rely on classic PEAR include_path
38+
require_once 'Image/Canvas.php';
39+
}
3440

3541
$canvas =& Image_Canvas::factory('jpg', array('width' => 600, 'height' => 600, 'quality' => 90));
3642

tests/lineends.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@
2727
* @link http://pear.php.net/package/Image_Canvas
2828
*/
2929

30-
require_once 'vendor/autoload.php';
30+
if (file_exists('vendor/autoload.php')) {
31+
// use composer if available
32+
require_once 'vendor/autoload.php';
33+
} else {
34+
// otherwise rely on classic PEAR include_path
35+
require_once 'Image/Canvas.php';
36+
}
3137

3238
$font = array('name' => 'Verdana', 'size' => 10);
3339

tests/pdf.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@
3030
// SPECIFY HERE WHERE A TRUETYPE FONT CAN BE FOUND
3131
$testFont = 'c:/windows/fonts/Arial.ttf';
3232

33-
require_once 'vendor/autoload.php';
33+
if (file_exists('vendor/autoload.php')) {
34+
// use composer if available
35+
require_once 'vendor/autoload.php';
36+
} else {
37+
// otherwise rely on classic PEAR include_path
38+
require_once 'Image/Canvas.php';
39+
}
3440

3541
$canvas =& Image_Canvas::factory('pdf', array('page' => 'A4', 'align' => 'center', 'width' => 600, 'height' => 600));
3642

tests/png.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@
3030
// SPECIFY HERE WHERE A TRUETYPE FONT CAN BE FOUND
3131
$testFont = 'c:/windows/fonts/Arial.ttf';
3232

33-
require_once 'vendor/autoload.php';
33+
if (file_exists('vendor/autoload.php')) {
34+
// use composer if available
35+
require_once 'vendor/autoload.php';
36+
} else {
37+
// otherwise rely on classic PEAR include_path
38+
require_once 'Image/Canvas.php';
39+
}
3440

3541
$canvas =& Image_Canvas::factory('png', array('width' => 600, 'height' => 600));
3642

tests/ps.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@
3030
// SPECIFY HERE WHERE A TRUETYPE FONT CAN BE FOUND
3131
$testFont = 'c:/windows/fonts/Arial.ttf';
3232

33-
require_once 'vendor/autoload.php';
33+
if (file_exists('vendor/autoload.php')) {
34+
// use composer if available
35+
require_once 'vendor/autoload.php';
36+
} else {
37+
// otherwise rely on classic PEAR include_path
38+
require_once 'Image/Canvas.php';
39+
}
3440

3541
$canvas =& Image_Canvas::factory('ps', array('page' => 'A4', 'align' => 'center', 'width' => 600, 'height' => 600, 'filename'=>'testps.ps'));
3642

tests/svg.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@
3030
// SPECIFY HERE WHERE A TRUETYPE FONT CAN BE FOUND
3131
$testFont = 'c:/windows/fonts/Arial.ttf';
3232

33-
require_once 'vendor/autoload.php';
33+
if (file_exists('vendor/autoload.php')) {
34+
// use composer if available
35+
require_once 'vendor/autoload.php';
36+
} else {
37+
// otherwise rely on classic PEAR include_path
38+
require_once 'Image/Canvas.php';
39+
}
3440

3541
$canvas =& Image_Canvas::factory('svg', array('width' => 600, 'height' => 600));
3642

tests/text.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@
2727
* @link http://pear.php.net/package/Image_Canvas
2828
*/
2929

30-
require_once 'vendor/autoload.php';
30+
if (file_exists('vendor/autoload.php')) {
31+
// use composer if available
32+
require_once 'vendor/autoload.php';
33+
} else {
34+
// otherwise rely on classic PEAR include_path
35+
require_once 'Image/Canvas.php';
36+
}
3137

3238
$canvas =& Image_Canvas::factory(
3339
'png',

0 commit comments

Comments
 (0)