Commit f44a1ecd authored by Jacob Priddy's avatar Jacob Priddy 👌
Browse files

Updates:

update to php 8
laravel apidoc genrator -> scribe
Stop using xdebug cause its not working in phpstorm+docker :(
laravel 8
parent 68d972b3
Pipeline #13190 passed with stages
in 2 minutes and 45 seconds
FROM php:7.4-fpm-alpine
FROM php:8.0-fpm-alpine
ENV PROJECT_DIR /var/www
......@@ -20,10 +20,10 @@ RUN apk update && apk add --no-cache \
coreutils \
rsync \
npm\
&& apk add --no-cache $PHPIZE_DEPS \
&& npm install -g @vue/cli \
&& pecl install xdebug \
&& docker-php-ext-enable xdebug
&& apk add --no-cache $PHPIZE_DEPS
# && npm install -g @vue/cli \
# && pecl install xdebug \
# && docker-php-ext-enable xdebug
# Install PHP Extensions
RUN docker-php-ext-install pdo \
......
error_reporting = E_ALL
display_startup_errors = On
display_errors = On
xdebug.remote_enable=1
xdebug.remote_connect_back=1
xdebug.idekey="PHPSTORM"
xdebug.remote_port=9000
xdebug.remote_autostart=1
# DockerNAT gateway IP
xdebug.remote.host=host.docker.internal
xdebug.remote.mode=req
xdebug.remote.handler=dbgp
;xdebug.mode=debug
;xdebug.start_with_request=yes
;xdebug.idekey="PHPSTORM"
; DockerNAT gateway IP
;xdebug.client_host=host.docker.internal
date.timezone = "America/Los_Angeles"
memory_limit = 256M
FROM php:7.4-fpm-alpine
FROM php:8.0-fpm-alpine
ENV PROJECT_DIR /var/www
......
......@@ -4,24 +4,24 @@
namespace App\Documentation\Strategies;
use ReflectionClass;
use ReflectionMethod;
use Illuminate\Routing\Route;
use Mpociot\ApiDoc\Tools\DocumentationConfig;
use Mpociot\ApiDoc\Extracting\Strategies\Strategy;
use ReflectionFunctionAbstract;
use Knuckles\Scribe\Tools\DocumentationConfig;
use Knuckles\Scribe\Extracting\Strategies\Strategy;
class ApplicationRepositoryResetStrategy extends Strategy
{
public function __construct(string $stage, DocumentationConfig $config)
public function __construct(DocumentationConfig $config)
{
// Set the config to use in memory implementations
config(['app.env', 'memory']);
parent::__construct($stage, $config);
parent::__construct($config);
}
/**
* @inheritDoc
*/
public function __invoke(Route $route, ReflectionClass $controller, ReflectionMethod $method, array $routeRules, array $context = [])
public function __invoke(Route $route, ReflectionClass $controller, ReflectionFunctionAbstract $method, array $routeRules, array $alreadyExtractedData = [])
{
return null;
}
......
......@@ -4,22 +4,22 @@
namespace App\Documentation\Strategies;
use ReflectionClass;
use ReflectionMethod;
use Illuminate\Routing\Route;
use Mpociot\ApiDoc\Extracting\Strategies\Strategy;
use ReflectionFunctionAbstract;
use Knuckles\Scribe\Extracting\Strategies\Strategy;
class BodyAuthenticationStrategy extends Strategy
{
/**
* @inheritDoc
*/
public function __invoke(Route $route, ReflectionClass $controller, ReflectionMethod $method, array $routeRules, array $context = [])
public function __invoke(Route $route, ReflectionClass $controller, ReflectionFunctionAbstract $method, array $routeRules, array $alreadyExtractedData = [])
{
if (in_array('GET', $route->methods(), true)) {
return null;
}
if (!$context['metadata']['authenticated']) {
if (!$alreadyExtractedData['metadata']['authenticated']) {
return null;
}
......
......@@ -4,22 +4,22 @@
namespace App\Documentation\Strategies;
use ReflectionClass;
use ReflectionMethod;
use Illuminate\Routing\Route;
use Mpociot\ApiDoc\Extracting\Strategies\Strategy;
use ReflectionFunctionAbstract;
use Knuckles\Scribe\Extracting\Strategies\Strategy;
class GetAuthenticationStrategy extends Strategy
{
/**
* @inheritDoc
*/
public function __invoke(Route $route, ReflectionClass $controller, ReflectionMethod $method, array $routeRules, array $context = [])
public function __invoke(Route $route, ReflectionClass $controller, ReflectionFunctionAbstract $method, array $routeRules, array $alreadyExtractedData = [])
{
if (!in_array('GET', $route->methods(), true)) {
return null;
}
if (!$context['metadata']['authenticated']) {
if (!$alreadyExtractedData['metadata']['authenticated']) {
return null;
}
......
......@@ -4,10 +4,10 @@
namespace App\Documentation\Strategies;
use ReflectionClass;
use ReflectionMethod;
use RuntimeException;
use Illuminate\Routing\Route;
use Mpociot\ApiDoc\Extracting\Strategies\Strategy;
use ReflectionFunctionAbstract;
use Knuckles\Scribe\Extracting\Strategies\Strategy;
class GoodResponseValidationStrategy extends Strategy
{
......@@ -22,13 +22,13 @@ class GoodResponseValidationStrategy extends Strategy
/**
* @inheritDoc
*/
public function __invoke(Route $route, ReflectionClass $controller, ReflectionMethod $method, array $routeRules, array $context = [])
public function __invoke(Route $route, ReflectionClass $controller, ReflectionFunctionAbstract $method, array $routeRules, array $alreadyExtractedData = [])
{
if (in_array($route->getName(), self::EXCLUDED, true)) {
return null;
}
foreach ($context['responses'] as $response) {
foreach ($alreadyExtractedData['responses'] as $response) {
$status = $response['status'] ?? 0;
if ($status < 300 && $status >= 200) {
return null;
......
......@@ -4,16 +4,16 @@
namespace App\Documentation\Strategies;
use ReflectionClass;
use ReflectionMethod;
use Illuminate\Routing\Route;
use Mpociot\ApiDoc\Extracting\Strategies\Strategy;
use ReflectionFunctionAbstract;
use Knuckles\Scribe\Extracting\Strategies\Strategy;
class PaginationStrategy extends Strategy
{
/**
* @inheritDoc
*/
public function __invoke(Route $route, ReflectionClass $controller, ReflectionMethod $method, array $routeRules, array $context = [])
public function __invoke(Route $route, ReflectionClass $controller, ReflectionFunctionAbstract $method, array $routeRules, array $alreadyExtractedData = [])
{
if (!in_array('GET', $route->methods(), true)) {
return null;
......
......@@ -4,18 +4,18 @@
namespace App\Documentation\Strategies;
use ReflectionClass;
use ReflectionMethod;
use Illuminate\Routing\Route;
use Mpociot\ApiDoc\Extracting\Strategies\Strategy;
use ReflectionFunctionAbstract;
use Knuckles\Scribe\Extracting\Strategies\Strategy;
class UnauthenticatedResponseStrategy extends Strategy
{
/**
* @inheritDoc
*/
public function __invoke(Route $route, ReflectionClass $controller, ReflectionMethod $method, array $routeRules, array $context = [])
public function __invoke(Route $route, ReflectionClass $controller, ReflectionFunctionAbstract $method, array $routeRules, array $alreadyExtractedData = [])
{
if (!$context['metadata']['authenticated']) {
if (!$alreadyExtractedData['metadata']['authenticated']) {
return null;
}
......
......@@ -2,6 +2,7 @@
namespace App\Providers;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
......@@ -23,6 +24,6 @@ class AppServiceProvider extends ServiceProvider
*/
public function boot()
{
//
Paginator::useBootstrap();
}
}
......@@ -12,21 +12,21 @@
"devmarketer/easynav": "^1.0",
"fideloper/proxy": "^4.0",
"fruitcake/laravel-cors": "^1.0",
"laravel/framework": "^7.0",
"laravel/framework": "^8.0",
"laravel/tinker": "^2.0",
"laravel/ui": "^2.0",
"laravel/ui": "^3.0",
"rlanvin/php-rrule": "^2.2",
"ext-json": "*"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.4",
"facade/ignition": "^2.0",
"facade/ignition": "^2.3.6",
"friendsofphp/php-cs-fixer": "^2.16",
"fzaninotto/faker": "^1.4",
"knuckleswtf/scribe": "^1.0.0",
"mockery/mockery": "^1.0",
"mpociot/laravel-apidoc-generator": "^4.8",
"nunomaduro/collision": "^4.1",
"phpunit/phpunit": "^8.5",
"nunomaduro/collision": "^5.0",
"phpunit/phpunit": "^9.5",
"roave/security-advisories": "dev-master"
},
"config": {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
<?php
return [
/*
* The type of documentation output to generate.
* - "static" will generate a static HTMl page in the /public/docs folder,
* - "laravel" will generate the documentation as a Blade view, so you can add routing and authentication.
*/
'type' => 'static',
/*
* Settings for `static` type output.
*/
'static' => [
/*
* HTML documentation, assets and Postman collection will be generated to this folder.
* Source Markdown will still be in resources/docs.
*/
'output_path' => 'public/docs',
],
/*
* Settings for `laravel` type output.
*/
'laravel' => [
/*
* Whether to automatically create a docs endpoint for you to view your generated docs.
* If this is false, you can still set up routing manually.
*/
'add_routes' => true,
/*
* URL path to use for the docs endpoint (if `add_routes` is true).
* By default, `/docs` opens the HTML page, and `/docs.json` downloads the Postman collection.
*/
'docs_url' => '/docs',
/*
* Middleware to attach to the docs endpoint (if `add_routes` is true).
*/
'middleware' => [],
],
/*
* How is your API authenticated? This information will be used in the displayed docs, generated examples and response calls.
*/
'auth' => [
/*
* Set this to true if your API is authenticated.
*/
'enabled' => true,
/*
* Where is the auth value meant to be sent in a request?
* Options: query, body, query_or_body, basic, bearer, header (for custom header)
*/
'in' => 'bearer',
/*
* The name of the parameter (eg token, key, apiKey) or header (eg Authorization, Api-Key).
*/
'name' => 'api_token',
/*
* The value of the parameter to be used by Scribe to authenticate response calls.
* This will NOT be included in the generated documentation.
* If this value is empty, Scribe will use a random value.
*/
'use_value' => 'token_string_admin',
/*
* Placeholder your users will see for the auth parameter in the example requests.
* If this value is null, Scribe will use a random value.
*/
'placeholder' => '{API_TOKEN}',
/*
* Any extra authentication-related info for your users. For instance, you can describe how to find or generate their auth credentials.
* Markdown and HTML are supported.
*/
'extra_info' => 'You can retrieve recieve a temporary token by using the login api, or by requesting a permanent API token from an ELock Admin.',
],
/*
* Text to place in the "Introduction" section, right after the `description`. Markdown and HTML are supported.
*/
'intro_text' => <<<INTRO
Welcome to our API documentation!
<aside>As you scroll, you'll see code examples for working with the API in different programming languages in the dark area to the right (or as part of the content on mobile), and you can switch the programming language of the examples with the tabs in the top right (or from the nav menu at the top left on mobile).</aside>
INTRO
,
/*
* Example requests for each endpoint will be shown in each of these languages.
* Supported options are: bash, javascript, php, python
* You can add a language of your own, but you must publish the package's views
* and define a corresponding view for it in the partials/example-requests directory.
* See https://scribe.readthedocs.io/en/latest/generating-documentation.html
*
*/
'example_languages' => [
'bash',
'javascript',
'php',
'python',
],
/*
* The base URL to be used in examples.
* If this is null, Scribe will use the value of config('app.url').
*/
'base_url' => null,
/*
* The HTML <title> for the generated documentation, and the name of the generated Postman collection.
* If this is null, Scribe will infer it from config('app.name').
*/
'title' => 'Elock API',
'description' => '',
/*
* Generate a Postman collection in addition to HTML docs.
* For 'static' docs, the collection will be generated to public/docs/collection.json.
* For 'laravel' docs, it will be generated to storage/app/scribe/collection.json.
* Setting `laravel.add_routes` to true (above) will also add a route for the collection.
* Collection schema: https://schema.getpostman.com/json/collection/v2.0.0/collection.json
*/
'postman' => [
'enabled' => true,
/*
* Manually override some generated content in the spec. Dot notation is supported.
*/
'overrides' => [
// 'info.version' => '2.0.0',
],
],
/*
* Generate an OpenAPI spec file in addition to docs webpage.
* For 'static' docs, the collection will be generated to public/docs/openapi.yaml.
* For 'laravel' docs, it will be generated to storage/app/scribe/openapi.yaml.
* Setting `laravel.add_routes` to true (above) will also add a route for the spec.
*/
'openapi' => [
'enabled' => true,
/*
* Manually override some generated content in the spec. Dot notation is supported.
*/
'overrides' => [
// 'info.version' => '2.0.0',
],
],
/*
* Name for the group of endpoints which do not have a @group set.
*/
'default_group' => 'General',
/*
* Custom logo path. This will be used as the value of the src attribute for the <img> tag,
* so make sure it points to a public URL or path accessible from your web server. For best results, the image width should be 230px.
* Set this to false to not use a logo.
*
* For example, if your logo is in public/img:
* - 'logo' => '../img/logo.png' // for `static` type (output folder is public/docs)
* - 'logo' => 'img/logo.png' // for `laravel` type
*
*/
'logo' => '../img/api-docs-logo.png',
/*
* The router your API is using (Laravel or Dingo).
*/
'router' => 'laravel',
/*
* The routes for which documentation should be generated.
* Each group contains rules defining which routes should be included ('match', 'include' and 'exclude' sections)
* and settings which should be applied to them ('apply' section).
*/
'routes' => [
/*
*
*
*
* ME ROUTES
*
*
*
*/
[
/*
* Specify conditions to determine what routes will be parsed in this group.
* A route must fulfill ALL conditions to pass.
*/
'match' => [
/*
* Match only routes whose domains match this pattern (use * as a wildcard to match any characters).
*/
'domains' => [
'*',
// 'domain1.*',
],
/*
* Match only routes whose paths match this pattern (use * as a wildcard to match any characters).
*/
'prefixes' => [
// 'api/me/*',
// 'api/me'
// 'users/*',
],
],
/*
* Include these routes when generating documentation,
* even if they did not match the rules above.
* Note that the route must be referenced by name here (wildcards are supported).
*/
'include' => [
'me.*',
// 'users.index', 'healthcheck*'
],
/*
* Exclude these routes when generating documentation,
* even if they matched the rules above.
* Note that the route must be referenced by name here (wildcards are supported).
*/
'exclude' => [
'web.*',
// 'users.create', 'admin.*'
],
/*
* Specify rules to be applied to all the routes in this group when generating documentation
*/
'apply' => [
/*
* Specify headers to be added to the example requests
*/
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Authorization' => 'Bearer token_string_engr',
// 'Api-Version' => 'v2',
],
/*
* If no @response or @transformer declarations are found for the route,
* we'll try to get a sample response by attempting an API call.
* Configure the settings for the API call here.
*/
'response_calls' => [
/*
* API calls will be made only for routes in this group matching these HTTP methods (GET, POST, etc).
* List the methods here or use '*' to mean all methods. Leave empty to disable API calls.
*/
'methods' => ['*'],
/*
* Laravel config variables which should be set for the API call.
* This is a good place to ensure that notifications, emails
* and other external services are not triggered
* during the documentation API calls
*/
'config' => [
'app.env' => 'memory',
'app.debug' => false,
// 'service.key' => 'value',
],
],
],
],
/*
*
*
*
* DOOR ROUTES
*
*
*
*
*/
[
/*
* Specify conditions to determine what routes will be parsed in this group.
* A route must fulfill ALL conditions to pass.
*/
'match' => [
/*
* Match only routes whose domains match this pattern (use * as a wildcard to match any characters).
*/
'domains' => [
'*',
// 'domain1.*',
],
/*
* Match only routes whose paths match this pattern (use * as a wildcard to match any characters).
*/
'prefixes' => [
],
],
/*
* Include these routes when generating documentation,
* even if they did not match the rules above.
* Note that the route must be referenced by name here (wildcards are supported).
*/
'include' => [
'door.*',
],
/*
* Exclude these routes when generating documentation,
* even if they matched the rules above.
* Note that the route must be referenced by name here (wildcards are supported).
*/
'exclude' => [
// 'users.create', 'admin.*'
],
/*
* Specify rules to be applied to all the routes in this group when generating documentation
*/
'apply' => [
/*
* Specify headers to be added to the example requests
*/
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Authorization' => 'Bearer door_1_api_token',
'Door-Controller-Version' => 'Api Doc Generator Client'
],
/*
* If no @response or @transformer declarations are found for the route,
* we'll try to get a sample response by attempting an API call.
* Configure the settings for the API call here.
*/
'response_calls' => [
/*
* API calls will be made only for routes in this group matching these HTTP methods (GET, POST, etc).
* List the methods here or use '*' to mean all methods. Leave empty to disable API calls.
*/
'methods' => ['*'],