Browse Source

Merge pull request #286 from dmelo/composer-compat

change Pico's default `index.php` to be compatible with `composer require picocms/pico`
Daniel Rudolf 9 years ago
parent
commit
f97cd83cc8
2 changed files with 12 additions and 1 deletions
  1. 1 0
      CHANGELOG.md
  2. 11 1
      index.php

+ 1 - 0
CHANGELOG.md

@@ -19,6 +19,7 @@ Released: -
           (RFC 3986) in `Page::evaluateRequestUrl()`
 * [Fixed] #272: Encode URLs using `rawurlencode()` in `Pico::getPageUrl()`
 * [Fixed] #274: Prevent double slashes in `base_url`
+* [Fixed] #285: Make `index.php` work when installed as a composer dependency
 ```
 
 ### Version 1.0.0-beta.1

+ 11 - 1
index.php

@@ -1,6 +1,16 @@
 <?php
+
 // load dependencies
-require_once(__DIR__ . '/vendor/autoload.php');
+if(is_file($f = __DIR__ . '/vendor/autoload.php')) {
+    // local composer install
+    require_once($f);
+} elseif(is_file($f = __DIR__ . '/../../../vendor/autoload.php')) {
+    // root composer install
+    require_once($f);
+} else {
+    // composer needs install...
+    die('Cannot find composer `/vendor/autoload.php` -- try `composer install`');
+}
 
 // instance Pico
 $pico = new Pico(