From 1febb1a4148da7a853f46ce7dc43935f9a2f3f20 Mon Sep 17 00:00:00 2001 From: Beanow Date: Sun, 8 Feb 2015 18:24:49 +0100 Subject: [PATCH] Switched to composer generated autoloader. --- .gitignore | 1 + README.md | 16 ++++++++++++++-- autoload.php | 41 ----------------------------------------- composer.json | 11 +++++++++++ example.php | 2 +- index.php | 2 +- 6 files changed, 28 insertions(+), 45 deletions(-) delete mode 100644 autoload.php create mode 100644 composer.json diff --git a/.gitignore b/.gitignore index 11eaf823..d5b3a7d4 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ #* favicon.* tests/coverage.html +/vendor \ No newline at end of file diff --git a/README.md b/README.md index fd47fc6c..a5cc9cb5 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,18 @@ -# Friendica Global Directory +# Decentralized Friendica Directory -Example cronjob. +## Installing + +### 1. Create an autoloader with composer + +Make sure you have composer installed globally, or rewrite the command to use a `.phar`. + +```sh +composer dump-autoload +``` + +### 2. Set up the cronjobs. + +Example cronjob using `www-data` user. ``` */30 * * * * www-data cd /var/www/friendica-directory; php include/cron_maintain.php diff --git a/autoload.php b/autoload.php deleted file mode 100644 index 0ac5f982..00000000 --- a/autoload.php +++ /dev/null @@ -1,41 +0,0 @@ - array( - __DIR__ . '/src', - __DIR__ . '/tests/unit/src', - ), - ); - - // go through the prefixes - foreach ($prefixes as $prefix => $dirs) { - - // does the requested class match the namespace prefix? - $prefix_len = strlen($prefix); - if (substr($class, 0, $prefix_len) !== $prefix) { - continue; - } - - // strip the prefix off the class - $class = substr($class, $prefix_len); - - // a partial filename - $part = str_replace('\\', DIRECTORY_SEPARATOR, $class) . '.php'; - - // go through the directories to find classes - foreach ($dirs as $dir) { - $dir = str_replace('/', DIRECTORY_SEPARATOR, $dir); - $file = $dir . DIRECTORY_SEPARATOR . $part; - if (is_readable($file)) { - require $file; - return; - } - } - } - -}); diff --git a/composer.json b/composer.json new file mode 100644 index 00000000..9dd0b869 --- /dev/null +++ b/composer.json @@ -0,0 +1,11 @@ +{ + "name": "friendica/dir", + "description": "The internet is our social network", + "license": "AGPL3", + "autoload": { + "psr-4": {"Friendica\\Directory\\": "src"} + }, + "require": { + "php": ">=5.3" + } +} \ No newline at end of file diff --git a/example.php b/example.php index 6f37fe3f..5f4ef6c8 100644 --- a/example.php +++ b/example.php @@ -1,7 +1,7 @@