-
Notifications
You must be signed in to change notification settings - Fork 3
fix deprication errors #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Jay-ponda-improwised
wants to merge
36
commits into
Local-Data-Exchange:master
Choose a base branch
from
Jay-ponda-improwised:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
bc16f6f
default object attributes
Jay-ponda-improwised 80c0ccc
Merge branch 'release/0.0.1'
Jay-ponda-improwised 780b4ab
Merge tag '0.0.1' into develop
Jay-ponda-improwised efcd1dc
rename project
Jay-ponda-improwised 2cc0f94
added error attribute
Jay-ponda-improwised f708fda
Revert "rename project"
Jay-ponda-improwised 596abb3
Merge branch 'release/0.0.2'
Jay-ponda-improwised 6a82eb8
Merge tag '0.0.2' into develop
Jay-ponda-improwised 51097bf
mock xml api call
Jay-ponda-improwised d3f75fb
Merge branch 'release/0.0.3'
Jay-ponda-improwised a9e1122
Merge tag '0.0.3' into develop
Jay-ponda-improwised 53ab025
fix whitespace probleam and typos and put log
Jay-ponda-improwised 99275ea
Merge branch 'release/0.0.4'
Jay-ponda-improwised 9847ad8
Merge tag '0.0.4' into develop
Jay-ponda-improwised aa45421
fix whitespace probleam
Jay-ponda-improwised 35a4215
Merge branch 'release/0.0.5'
Jay-ponda-improwised 23b9892
Merge tag '0.0.5' into develop
Jay-ponda-improwised 6e78a3f
remove deprication warning
Jay-ponda-improwised 793a5af
Merge branch 'Local-Data-Exchange:master' into develop
Jay-ponda-improwised 67a4d69
Merge pull request #2 from Jay-ponda-improwised/feature/remove-depric…
Jay-ponda-improwised 42b1ce7
fix docker file
Jay-ponda-improwised 4844dd8
fix whitespace issue
Jay-ponda-improwised fc15a23
remove unwanted items from dockerignore
Jay-ponda-improwised d82fa59
Merge branch 'feature/added-testcase-and-coverage' into develop
Jay-ponda-improwised 08c3c58
Merge branch 'Local-Data-Exchange:master' into master
Jay-ponda-improwised 1d13562
rename files to have develop prefix
Jay-ponda-improwised a515ac5
added direct alias for test and coverage, so without going to image; …
Jay-ponda-improwised 2f5a98a
Merge pull request #5 from Jay-ponda-improwised/feature/constistant-d…
Jay-ponda-improwised ce93f2a
Merge branch 'release/0.0.6'
Jay-ponda-improwised 01d867b
Merge tag '0.0.6' into develop
Jay-ponda-improwised 9d6d219
feat: make install at build time
Jay-ponda-improwised 6b254eb
Merge pull request #6 from Jay-ponda-improwised/feature/change-docker…
Jay-ponda-improwised 0f5b184
feat: added fix version, remove update
Jay-ponda-improwised 89bfd71
feat: update main config to run php 8.1
Jay-ponda-improwised 7932cf9
feat: change larabel version
Jay-ponda-improwised dfc4413
Merge branch 'release/0.0.7'
Jay-ponda-improwised File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,2 @@ | ||
| vendor/ | ||
| coverage |
This file contains hidden or 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 |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| .DS_Store | ||
| .phpunit.result.cache | ||
|
|
||
| vendor/ | ||
| vendor/ | ||
| coverage |
This file contains hidden or 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,9 @@ | ||
| { | ||
| "cSpell.words": [ | ||
| "cimg", | ||
| "laravel", | ||
| "PCOV", | ||
| "pecl", | ||
| "phpunit" | ||
| ] | ||
| } |
This file contains hidden or 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,205 @@ | ||
| <!-- PROJECT LOGO --> | ||
| <br /> | ||
| <p align="center"> | ||
| <a href="https://www.localdataexchange.com"> | ||
| <img src="https://staging-ipromote.ldex.co/ctm/LDE_Logo-Black.png" alt="Logo" width="" height="80"> | ||
| </a> | ||
|
|
||
| <h3 align="center">Api Helper Package - Developer Guide</h3> | ||
|
|
||
| <p align="center"> | ||
| A package to consume api smoothly | ||
| <br /> | ||
| <a href="#table-of-contents"><strong>Explore the docs »</strong></a> | ||
| <br /> | ||
| <br /> | ||
| <a href="https://packagist.org/packages/lde/api-helper">View Package</a> | ||
| · | ||
| <a href="https://github.com/Local-Data-Exchange/api-helper/issues">Report Bug</a> | ||
| · | ||
| <a href="https://github.com/Local-Data-Exchange/api-helper/issues">Request Feature</a> | ||
| </p> | ||
| </p> | ||
|
|
||
|
|
||
|
|
||
| <!-- TABLE OF CONTENTS --> | ||
| ## Table of Contents | ||
|
|
||
| * [Getting Started](#getting-started) | ||
| * [Installation](#installation) | ||
| * [Configuration](#configuration) | ||
| * [Usage](#usage) | ||
| * [Methods](#methods) | ||
| * [Response](#response) | ||
| * [Docker Development Setup](#docker-development-setup) | ||
| * [Prerequisites](#prerequisites) | ||
| * [Getting Started](#getting-started-1) | ||
| * [Volume Mounting](#volume-mounting) | ||
| * [Running Tests](#running-tests) | ||
| * [Running Tests with Coverage](#running-tests-with-coverage) | ||
| * [Development Workflow](#development-workflow) | ||
|
|
||
|
|
||
| ## Getting Started | ||
|
|
||
| This package is useful to consume API's, here is the instruction for installation and usage. | ||
|
|
||
| ## Installation | ||
|
|
||
| 1. To install this package using [Packagist](https://packagist.org/packages/lde/api-helper) | ||
|
|
||
| 2. On the root of your project run following command | ||
|
|
||
| composer require lde/api-helper | ||
|
|
||
| 3. This command will install package with dependency | ||
|
|
||
| ## Configuration | ||
|
|
||
| - To use this apihelper need to export config file to do so run the following command in your terminal to publish config file to config folder. | ||
|
|
||
| php artisan vendor:publish --provider="Lde\ApiHelper\ApiHelperServiceProvider" | ||
|
|
||
| - This will publish config file naming **api_helper.php** into config folder. | ||
|
|
||
| ## Prometheus Configuration | ||
| - Prometheus is dependent on your app so you need to provide prometheus configuration and also use below packages on your app. | ||
|
|
||
| - [jimdo/prometheus_client_php](https://github.com/Jimdo/prometheus_client_php) | ||
| - [superbalist/laravel-prometheus-exporter](https://github.com/Superbalist/laravel-prometheus-exporter) | ||
| - If you want to use prometheus then you should turn it on from config [api_helper](src/Config/api_helper.php) | ||
| ```php | ||
| 'log_stats' => true, // If you want to use prometheus then set as true otherwise false | ||
|
|
||
| 'prometheus' => [ | ||
| 'labels' => [ | ||
| 'client_id' => 10, | ||
| 'app' => 'api-helper', | ||
| 'source' => 'core', | ||
| ], | ||
| 'histogram_bucket' => [0.1, 0.25, 0.5, 0.75, 1.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 7.5, 10.0], | ||
| ], | ||
| ``` | ||
| - You can configure labels of prometheus inside `prometheus.labels` as per your need. | ||
| - `histogram_bucket` you can set inside prometheus config as array. | ||
|
|
||
| ## Usage | ||
|
|
||
| - To use this package you need to add following class where you want to use this package. | ||
|
|
||
| use Lde\ApiHelper\ApiBuilder; | ||
|
|
||
|
|
||
| ### Methods | ||
|
|
||
| #### addHeaders($headers) | ||
|
|
||
| - This method is use to add headers. | ||
|
|
||
| - It accept name and value as parameter, Here you can set only one header at a time. | ||
|
|
||
|
|
||
| $headers['Accept'] = "application/json"; | ||
| $headers['Content-Type'] = "application/json"; | ||
| app(ApiBuilder::class)->addHeaders($headers); | ||
|
|
||
| - We will get response in form of object of ApiBuilder. | ||
|
|
||
|
|
||
| #### api($connection) | ||
|
|
||
| - This method is use to set api that we are going to use from *api_helper.php* , there is httpbin and mokbin is define so you have to pass the name that you want to use. | ||
|
|
||
| - You can also define your own api end point at *api_helper.php* in config file. | ||
|
|
||
| app(ApiBuilder::class)->api('httpbin')->method_to_call(); | ||
|
|
||
| - The snippet indicates how you can connect particular api and access their method. | ||
|
|
||
| - method_to_call() is the function that you have specified inside *api_helper* connection array. | ||
|
|
||
| - This will return object of ApiResponse. | ||
|
|
||
| ### Response | ||
|
|
||
| - Here you will get object in response, In each response you will get success either true or false | ||
| - You will also get status code for more information about response please check below doc. | ||
| - http://docs.guzzlephp.org/en/latest/psr7.html#responses | ||
|
|
||
| ## Docker Development Setup | ||
|
|
||
| This package includes a Docker development environment for easier testing and development. | ||
|
|
||
| ### Prerequisites | ||
|
|
||
| - Docker and Docker Compose installed on your system | ||
|
|
||
| ### Getting Started | ||
|
|
||
| 1. Build and start the Docker container: | ||
| ```bash | ||
| docker-compose -f develop-docker-compose.yaml up -d | ||
| ``` | ||
|
|
||
| 2. Enter the container to work with the code: | ||
| ```bash | ||
| docker exec -it api-helper bash | ||
| ``` | ||
|
|
||
| 3. Inside the container, the package will automatically install dependencies using Composer on first run. | ||
|
|
||
| ### Volume Mounting | ||
|
|
||
| The current directory is mounted to `/app` in the container. The `vendor` directory is excluded from the volume mount to prevent conflicts between host and container dependencies. | ||
|
|
||
| ### Running Tests | ||
|
|
||
| You can run the PHPUnit tests using our optimized wrapper script: | ||
|
|
||
| ```bash | ||
| docker exec api-helper /usr/local/bin/run-tests.sh | ||
| ``` | ||
|
|
||
| The tests run without Xdebug by default for better performance. PCOV is used for code coverage collection when needed. | ||
| The tests use the `develop.phpunit.xml` configuration file which is optimized for the Docker development environment. | ||
|
|
||
| ### Running Tests with Coverage | ||
|
|
||
| To run tests with code coverage reporting: | ||
|
|
||
| ```bash | ||
| docker exec api-helper /usr/local/bin/run-tests.sh coverage | ||
| ``` | ||
|
|
||
| This will generate an HTML coverage report in the `coverage` directory, which you can view by opening `coverage/index.html` in a web browser. | ||
|
|
||
| Note: Coverage reports require Xdebug to be enabled, which will slow down test execution. For regular development, use the standard test command for better performance. | ||
|
|
||
| ### Using Test Aliases | ||
|
|
||
| For convenience, the Docker container includes executable scripts for running tests: | ||
|
|
||
| ```bash | ||
| # Run tests without coverage (faster) | ||
| docker-compose -f develop-docker-compose.yaml exec api-helper test | ||
|
|
||
| # Run tests with coverage report | ||
| docker-compose -f develop-docker-compose.yaml exec api-helper test-coverage | ||
| ``` | ||
|
|
||
| These commands can be run directly from your host machine without entering the container. | ||
|
|
||
| You can also use them inside the container: | ||
|
|
||
| ```bash | ||
| docker exec -it api-helper bash | ||
| test # Run tests without coverage | ||
| test-coverage # Run tests with coverage | ||
| ``` | ||
|
|
||
| ### Development Workflow | ||
|
|
||
| 1. Make changes to the code on your host machine | ||
| 2. The changes will be immediately reflected in the container | ||
| 3. Run tests or other commands inside the container as needed | ||
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,8 +1,10 @@ | ||
| services: | ||
| api-helper: | ||
| image: circleci/php:7.4 | ||
| build: | ||
| context: . | ||
| dockerfile: develop.Dockerfile | ||
| container_name: api-helper | ||
| working_dir: /app | ||
| command: sleep infinity | ||
| volumes: | ||
| - .:/app | ||
| - /app/vendor |
This file contains hidden or 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,64 @@ | ||
| FROM cimg/php:8.1 | ||
|
|
||
| # Install system dependencies | ||
| USER root | ||
| RUN apt-get update && apt-get install -y \ | ||
| git \ | ||
| curl \ | ||
| libxml2-dev \ | ||
| zip \ | ||
| unzip | ||
|
|
||
| # Install PHP extensions including PCOV for code coverage | ||
| RUN pecl install pcov && \ | ||
| docker-php-ext-enable pcov && \ | ||
| docker-php-ext-install xml | ||
|
|
||
| # Install Composer | ||
| COPY --from=composer:2.8.12 /usr/bin/composer /usr/bin/composer | ||
|
|
||
| # Set working directory | ||
| WORKDIR /app | ||
|
|
||
| # Copy all files (excluding vendor directory due to .dockerignore) | ||
| COPY composer.json composer.lock ./ | ||
|
|
||
| # Install dependencies (update if lock file is out of sync) | ||
| RUN composer install --no-dev --optimize-autoloader --no-scripts | ||
|
|
||
| # Generate autoload files | ||
| RUN composer dump-autoload --optimize | ||
|
|
||
| # Copy other files and directories | ||
| COPY . . | ||
|
|
||
| # Create a script to run composer install when container starts | ||
| RUN echo '#!/bin/bash\n\ | ||
| echo "Running startup script..."\n\ | ||
| git config --global --add safe.directory /app\n\ | ||
| echo "Starting container..."\n\ | ||
| sleep infinity' > /start.sh && chmod +x /start.sh | ||
|
|
||
| # Create a wrapper script for running tests with coverage | ||
| RUN echo '#!/bin/bash\n\ | ||
| # Disable Xdebug by default for better performance\n\ | ||
| export PHP_IDE_CONFIG=\n\ | ||
| \n\ | ||
| # Enable Xdebug only when needed for coverage\n\ | ||
| if [ "$1" = "coverage" ]; then\n\ | ||
| echo "Enabling Xdebug for coverage report..."\n\ | ||
| php -d xdebug.mode=coverage ./vendor/bin/phpunit --configuration develop.phpunit.xml --coverage-html=coverage\n\ | ||
| else\n\ | ||
| # Run tests without Xdebug for better performance\n\ | ||
| echo "Running tests without Xdebug for better performance..."\n\ | ||
| php -n -d extension=/usr/local/lib/php/extensions/no-debug-non-zts-20190902/pcov.so ./vendor/bin/phpunit --configuration develop.phpunit.xml\n\ | ||
| fi' > /usr/local/bin/run-tests.sh && chmod +x /usr/local/bin/run-tests.sh | ||
|
|
||
| # Create executable scripts for easier test command execution | ||
| RUN echo '#!/bin/bash\n\ | ||
| /usr/local/bin/run-tests.sh "$@"' > /usr/local/bin/test && chmod +x /usr/local/bin/test && \ | ||
| echo '#!/bin/bash\n\ | ||
| /usr/local/bin/run-tests.sh coverage "$@"' > /usr/local/bin/test-coverage && chmod +x /usr/local/bin/test-coverage | ||
|
|
||
| # Keep container running | ||
| CMD ["/start.sh"] |
This file contains hidden or 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,25 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <phpunit bootstrap="vendor/autoload.php" | ||
| backupGlobals="false" | ||
| backupStaticAttributes="false" | ||
| colors="true" | ||
| verbose="true" | ||
| convertErrorsToExceptions="true" | ||
| convertNoticesToExceptions="true" | ||
| convertWarningsToExceptions="true" | ||
| processIsolation="true" | ||
| stopOnFailure="false"> | ||
| <testsuites> | ||
| <testsuite name="Api Helper Test Suite"> | ||
| <directory>tests</directory> | ||
| </testsuite> | ||
| </testsuites> | ||
| <filter> | ||
| <whitelist processUncoveredFilesFromWhitelist="true"> | ||
| <directory suffix=".php">src</directory> | ||
| <exclude> | ||
| <directory suffix=".php">src/Config</directory> | ||
| </exclude> | ||
| </whitelist> | ||
| </filter> | ||
| </phpunit> |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.