.github
2 years ago
documents
2 years ago
non_composer_tests
4 years ago
src
2 years ago
tests
2 years ago
.editorconfig
4 years ago
.travis.yml
4 years ago
CHANGELOG.md
2 years ago
LICENSE
4 years ago
README.md
2 years ago
Razorpay.php
2 years ago
composer.json
2 years ago
doc.md
4 years ago
phpunit.xml.dist
2 years ago
release.txt
4 years ago
Razorpay.php
55 lines
| 1 | <?php |
| 2 | |
| 3 | // Include Requests only if not already defined |
| 4 | if (class_exists('Requests') === false) |
| 5 | { |
| 6 | require_once __DIR__.'/libs/Requests-1.8.0/library/Requests.php'; |
| 7 | } |
| 8 | |
| 9 | try |
| 10 | { |
| 11 | Requests::register_autoloader(); |
| 12 | |
| 13 | if (version_compare(Requests::VERSION, '1.6.0') === -1) |
| 14 | { |
| 15 | throw new Exception('Requests class found but did not match'); |
| 16 | } |
| 17 | } |
| 18 | catch (\Exception $e) |
| 19 | { |
| 20 | throw new Exception('Requests class found but did not match'); |
| 21 | } |
| 22 | |
| 23 | spl_autoload_register(function ($class) |
| 24 | { |
| 25 | // project-specific namespace prefix |
| 26 | $prefix = 'Razorpay\Api'; |
| 27 | |
| 28 | // base directory for the namespace prefix |
| 29 | $base_dir = __DIR__ . '/src/'; |
| 30 | |
| 31 | // does the class use the namespace prefix? |
| 32 | $len = strlen($prefix); |
| 33 | |
| 34 | if (strncmp($prefix, $class, $len) !== 0) |
| 35 | { |
| 36 | // no, move to the next registered autoloader |
| 37 | return; |
| 38 | } |
| 39 | |
| 40 | // get the relative class name |
| 41 | $relative_class = substr($class, $len); |
| 42 | |
| 43 | // |
| 44 | // replace the namespace prefix with the base directory, |
| 45 | // replace namespace separators with directory separators |
| 46 | // in the relative class name, append with .php |
| 47 | // |
| 48 | $file = $base_dir . str_replace('\\', '/', $relative_class) . '.php'; |
| 49 | |
| 50 | // if the file exists, require it |
| 51 | if (file_exists($file)) |
| 52 | { |
| 53 | require $file; |
| 54 | } |
| 55 | }); |