-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(php): Add PHP clients init + PHP search client (#78)
- Loading branch information
Showing
278 changed files
with
99,947 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# ref: https://github.com/github/gitignore/blob/master/Composer.gitignore | ||
|
||
composer.phar | ||
/vendor/ | ||
|
||
# php-cs-fixer cache | ||
.php_cs.cache | ||
|
||
# PHPUnit cache | ||
.phpunit.result.cache | ||
|
||
.openapi-generator/ | ||
composer.lock |
16 changes: 16 additions & 0 deletions
16
clients/algoliasearch-client-php/.openapi-generator-ignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# OpenAPI Generator Ignore | ||
# Generated by openapi-generator https://github.com/openapitools/openapi-generator | ||
|
||
# Use this file to prevent files from being overwritten by the generator. | ||
# The patterns follow closely to .gitignore or .dockerignore. | ||
|
||
docs/** | ||
test/** | ||
|
||
.travis.yml | ||
phpunit.xml.dist | ||
README.md | ||
git_push.sh | ||
.php_cs | ||
|
||
lib/HeaderSelector.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
$config = new PhpCsFixer\Config(); | ||
|
||
return $config | ||
->setUsingCache(true) | ||
->setRules([ | ||
'array_syntax' => [ 'syntax' => 'short' ], | ||
'blank_line_after_namespace' => false, | ||
'blank_line_after_opening_tag' => true, | ||
'blank_line_before_statement' => true, | ||
'braces' => false, | ||
'cast_spaces' => true, | ||
'combine_consecutive_unsets' => true, | ||
'echo_tag_syntax' => true, | ||
'general_phpdoc_tag_rename' => true, | ||
'mb_str_functions' => true, | ||
'no_blank_lines_after_class_opening' => true, | ||
'no_empty_phpdoc' => true, | ||
'no_empty_statement' => true, | ||
'no_extra_blank_lines' => true, | ||
'no_multiline_whitespace_around_double_arrow' => true, | ||
'no_short_bool_cast' => true, | ||
'no_trailing_whitespace' => true, | ||
'no_trailing_whitespace_in_comment' => true, | ||
'no_unneeded_control_parentheses' => true, | ||
'no_unreachable_default_argument_value' => true, | ||
'no_unused_imports' => true, | ||
'no_useless_else' => true, | ||
'no_useless_return' => true, | ||
'no_whitespace_before_comma_in_array' => true, | ||
'no_whitespace_in_blank_line' => true, | ||
'normalize_index_brace' => true, | ||
'not_operator_with_space' => false, | ||
'object_operator_without_whitespace' => true, | ||
'ordered_imports' => true, | ||
'phpdoc_annotation_without_dot' => true, | ||
'phpdoc_inline_tag_normalizer' => true, | ||
'phpdoc_order' => true, | ||
'phpdoc_scalar' => true, | ||
'phpdoc_separation' => true, | ||
'phpdoc_single_line_var_spacing' => true, | ||
'phpdoc_tag_type' => true, | ||
'protected_to_private' => true, | ||
'@PSR2' => true, | ||
'short_scalar_cast' => true, | ||
'single_blank_line_at_eof' => false, | ||
'single_blank_line_before_namespace' => true, | ||
'single_quote' => true, | ||
'space_after_semicolon' => true, | ||
'standardize_not_equals' => true, | ||
'strict_comparison' => true, | ||
'strict_param' => true, | ||
'ternary_operator_spaces' => true, | ||
'trailing_comma_in_multiline' => true, | ||
'trim_array_spaces' => true, | ||
]) | ||
->setFinder( | ||
PhpCsFixer\Finder::create() | ||
->exclude('test') | ||
->exclude('tests') | ||
->in(__DIR__) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"name": "algolia/algoliasearch-client-php", | ||
"description": "API powering the features of Algolia.", | ||
"keywords": [ | ||
"openapitools", | ||
"openapi-generator", | ||
"openapi", | ||
"php", | ||
"sdk", | ||
"rest", | ||
"api" | ||
], | ||
"homepage": "https://openapi-generator.tech", | ||
"license": "unlicense", | ||
"authors": [ | ||
{ | ||
"name": "OpenAPI-Generator contributors", | ||
"homepage": "https://openapi-generator.tech" | ||
} | ||
], | ||
"require": { | ||
"php": "^7.3 || ^8.0", | ||
"ext-curl": "*", | ||
"ext-json": "*", | ||
"ext-mbstring": "*", | ||
"guzzlehttp/guzzle": "^7.3", | ||
"guzzlehttp/psr7": "^2.0", | ||
"psr/http-message": "^1.0", | ||
"psr/log": "^1.0 || ^2.0 || ^3.0", | ||
"psr/simple-cache": "^1.0 || ^2.0 || ^3.0" | ||
}, | ||
"require-dev": { | ||
"friendsofphp/php-cs-fixer": "^3.5.0" | ||
}, | ||
"autoload": { | ||
"psr-4": { "Algolia\\AlgoliaSearch\\" : "lib/" }, | ||
"files": [ | ||
"lib/Http/Psr7/functions.php" | ||
] | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { "Algolia\\AlgoliaSearch\\Test\\" : "test/" } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<?php | ||
|
||
namespace Algolia\AlgoliaSearch; | ||
|
||
use Algolia\AlgoliaSearch\Cache\NullCacheDriver; | ||
use Algolia\AlgoliaSearch\Http\HttpClientInterface; | ||
use Algolia\AlgoliaSearch\Log\DebugLogger; | ||
use Psr\Log\LoggerInterface; | ||
use Psr\SimpleCache\CacheInterface; | ||
|
||
final class Algolia | ||
{ | ||
const VERSION = '1.0.0'; | ||
|
||
/** | ||
* Holds an instance of the simple cache repository (PSR-16). | ||
* | ||
* @var \Psr\SimpleCache\CacheInterface|null | ||
*/ | ||
private static $cache; | ||
|
||
/** | ||
* Holds an instance of the logger (PSR-3). | ||
* | ||
* @var \Psr\Log\LoggerInterface|null | ||
*/ | ||
private static $logger; | ||
|
||
/** | ||
* @var \Algolia\AlgoliaSearch\Http\HttpClientInterface | ||
*/ | ||
private static $httpClient; | ||
|
||
public static function isCacheEnabled() | ||
{ | ||
if (null === self::$cache) { | ||
return false; | ||
} | ||
|
||
return !self::getCache() instanceof NullCacheDriver; | ||
} | ||
|
||
/** | ||
* Gets the cache instance. | ||
* | ||
* @return \Psr\SimpleCache\CacheInterface | ||
*/ | ||
public static function getCache() | ||
{ | ||
if (null === self::$cache) { | ||
self::setCache(new NullCacheDriver()); | ||
} | ||
|
||
return self::$cache; | ||
} | ||
|
||
/** | ||
* Sets the cache instance. | ||
*/ | ||
public static function setCache(CacheInterface $cache) | ||
{ | ||
self::$cache = $cache; | ||
} | ||
|
||
/** | ||
* Gets the logger instance. | ||
* | ||
* @return \Psr\Log\LoggerInterface | ||
*/ | ||
public static function getLogger() | ||
{ | ||
if (null === self::$logger) { | ||
self::setLogger(new DebugLogger()); | ||
} | ||
|
||
return self::$logger; | ||
} | ||
|
||
/** | ||
* Sets the logger instance. | ||
*/ | ||
public static function setLogger(LoggerInterface $logger) | ||
{ | ||
self::$logger = $logger; | ||
} | ||
|
||
public static function getHttpClient() | ||
{ | ||
if (null === self::$httpClient) { | ||
self::setHttpClient(new \Algolia\AlgoliaSearch\Http\GuzzleHttpClient()); | ||
} | ||
|
||
return self::$httpClient; | ||
} | ||
|
||
public static function setHttpClient(HttpClientInterface $httpClient) | ||
{ | ||
self::$httpClient = $httpClient; | ||
} | ||
|
||
public static function resetHttpClient() | ||
{ | ||
self::$httpClient = null; | ||
} | ||
} |
Oops, something went wrong.