diff options
author | Remi Collet <fedora@famillecollet.com> | 2015-10-14 14:39:34 +0200 |
---|---|---|
committer | Remi Collet <fedora@famillecollet.com> | 2015-10-14 14:39:34 +0200 |
commit | 461fac51d513a34c07af350be9f79f364826e99c (patch) | |
tree | baa99356a2eae4b8718a51c9a6beabb29b978f85 | |
parent | 86f09d7be4666093aee7595e775de93e0d18272d (diff) |
php-seld-cli-prompt: add autoloader
-rw-r--r-- | cli-prompt-autoload.php | 15 | ||||
-rw-r--r-- | php-seld-cli-prompt.spec | 29 |
2 files changed, 43 insertions, 1 deletions
diff --git a/cli-prompt-autoload.php b/cli-prompt-autoload.php new file mode 100644 index 0000000..1da2de3 --- /dev/null +++ b/cli-prompt-autoload.php @@ -0,0 +1,15 @@ +<?php +/* Autoloader for seld/cli-prompt and its dependencies */ + +$vendorDir = '/usr/share/php'; +// Use Symfony autoloader +if (!isset($fedoraClassLoader) || !($fedoraClassLoader instanceof \Symfony\Component\ClassLoader\ClassLoader)) { + if (!class_exists('Symfony\\Component\\ClassLoader\\ClassLoader', false)) { + require_once $vendorDir . '/Symfony/Component/ClassLoader/ClassLoader.php'; + } + + $fedoraClassLoader = new \Symfony\Component\ClassLoader\ClassLoader(); + $fedoraClassLoader->register(); +} + +$fedoraClassLoader->addPrefix('Seld\\CliPrompt\\', dirname(dirname(__DIR__))); diff --git a/php-seld-cli-prompt.spec b/php-seld-cli-prompt.spec index faedd79..e4d8df1 100644 --- a/php-seld-cli-prompt.spec +++ b/php-seld-cli-prompt.spec @@ -13,7 +13,7 @@ Name: php-seld-cli-prompt Version: 1.0.0 -Release: 1%{?dist} +Release: 3%{?dist} Summary: Allows you to prompt for user input on the command line Group: Development/Libraries @@ -21,9 +21,16 @@ License: MIT URL: https://github.com/%{gh_owner}/%{gh_project} Source0: https://github.com/%{gh_owner}/%{gh_project}/archive/%{gh_commit}/%{gh_project}-%{version}-%{gh_short}.tar.gz +# Autoloader +Source1: %{gh_project}-autoload.php + BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildArch: noarch BuildRequires: php(language) >= 5.3 +# For test +BuildRequires: php-cli +# Autoloader +BuildRequires: php-composer(symfony/class-loader) # From composer.json # "php": ">=5.3.0", @@ -31,6 +38,8 @@ Requires: php(language) >= 5.3.0 # From phpcompatifo report for 1.0.0 Requires: php-pcre Requires: php-spl +# Autoloader +Requires: php-composer(symfony/class-loader) Provides: php-composer(seld/cli-prompt) = %{version} @@ -41,10 +50,15 @@ need to prompt for sensitive information. In these cases, the characters typed in by the user should not be directly visible, and this is quite a pain to do in a cross-platform way. +To use this library, you just have to add, in your project: + require_once '%{_datadir}/php/Seld/CliPrompt/autoload.php'; + %prep %setup -q -n %{gh_project}-%{gh_commit} +cp %{SOURCE1} src/autoload.php + %build # Nothing @@ -57,6 +71,16 @@ mkdir -p %{buildroot}%{_datadir}/php/Seld/CliPrompt cp -pr src/* %{buildroot}%{_datadir}/php/Seld/CliPrompt/ +%check +: Check if our autoloader works +php -r ' +require "%{buildroot}%{_datadir}/php/Seld/CliPrompt/autoload.php"; +$a = new \Seld\CliPrompt\CliPrompt(); +echo "Ok\n"; +exit(0); +' + + %clean rm -rf %{buildroot} @@ -70,5 +94,8 @@ rm -rf %{buildroot} %changelog +* Wed Oct 14 2015 Remi Collet <remi@fedoraproject.org> - 1.0.0-3 +- add autoloader + * Mon May 4 2015 Remi Collet <remi@fedoraproject.org> - 1.0.0-1 - initial package
\ No newline at end of file |