/usr/home/basttyy/domains/api.sendmani.com/public_html/vendor/eyika/atom-framework/src/Http/Route.php
} elseif (is_array($callback) && count($callback) > 1) {
[$controller, $method] = $callback;
$controllerInstance = new $controller;
return call_user_func_array([$controllerInstance, $method], array_merge([$request], array_values($parameters)));
} elseif (is_string($callback)) {
return include_once __DIR__ . "/$callback";
} else {
throw new NotFoundHttpException('Route not found');
}
}
// Handle 404 Not Found
protected static function handleNotFound($request)
{
if (isset(self::$routes['ANY']['/404'])) {
$callback = self::$routes['ANY']['/404']['callback'];
return self::executeCallback($callback, $request, []);
}
throw new NotFoundHttpException('Requested resource not found');
}
}
Arguments
"Requested resource not found"
/usr/home/basttyy/domains/api.sendmani.com/public_html/vendor/eyika/atom-framework/src/Http/Route.php
foreach (self::$routes[$requestMethod] ?? [] as $route => $data) {
if (self::matchesRoute($route, $requestUri, $parameters)) {
$request->route_params = Arr::wrap(sanitize_data($parameters));
self::$currentRoute = $route;
$routeMatched = true;
break;
}
}
// Set up the middleware pipeline
$middlewares = array_merge(
static::$defaultMiddlewares,
static::findRouteMiddlewares($requestMethod, $requestUri)
);
// Core handler for the pipeline
$coreHandler = function ($request) use ($routeMatched, $requestMethod, $requestUri) {
// If no route matches, set up a 404 handler
if (!$routeMatched) {
return self::handleNotFound($request)->send();
}
$callback = self::$routes[$requestMethod][self::$currentRoute]['callback'];
return self::executeCallback($callback, $request, $request->route_params ?? []);
};
// Run the pipeline
$response = (new Pipeline())
->through($middlewares)
->then($coreHandler)
->run($request);
// Output the response
if ($response instanceof BaseResponse)
return $response->send();
elseif (is_string($response)) {
echo $response;
return true;
} else return true;
}
Arguments
Eyika\Atom\Framework\Http\Request {#158}
/usr/home/basttyy/domains/api.sendmani.com/public_html/vendor/eyika/atom-framework/src/Http/Middlewares/SubstituteBindings.php
use Eyika\Atom\Framework\Http\Request;
use Eyika\Atom\Framework\Support\Arr;
use Eyika\Atom\Framework\Support\Database\Contracts\ModelInterface;
use Eyika\Atom\Framework\Support\Database\Contracts\UserModelInterface;
use Eyika\Atom\Framework\Support\NamespaceHelper;
class SubstituteBindings implements MiddlewareInterface
{
/**
* Handle an incoming request.
*
* @throws NotFoundHttpException
*/
public function handle(Request $request, Closure $next, ...$ignoreKeys): BaseResponse
{
// Get the route parameters from the request
$routeParams = $request->route_params;
if (empty($routeParams))
return $next($request);
// Substitute bindings for each parameter
foreach ($routeParams as $key => $value) {
if (Arr::exists($ignoreKeys, $key))
continue;
if (is_numeric($value)) {
$value = sanitize_data($value);
// Example: replace `{user}` with an instance of User model
$model = $this->resolveModel($key, $value);
if ($model === null) {
continue;
}
if ($model) {
$routeParams[$key] = $model;
} else {
throw new ModelNotFoundException("unable to retrieve $key with id $value");
}
}
}
Arguments
Eyika\Atom\Framework\Http\Request {#158}
/usr/home/basttyy/domains/api.sendmani.com/public_html/vendor/eyika/atom-framework/src/Http/Pipeline.php
* Get the callable that wraps middleware around the next handler.
* Create the closure chain for the pipeline.
*
* @return callable
*/
protected function carry(): callable
{
return function (Closure $next, string|array|callable $pipe): callable {
return function (Request $passable) use ($next, $pipe) {
if (is_string($pipe) || is_array($pipe)) {
// Resolve middleware class and parameters
[$pipeClass, $parameters] = $this->resolveMiddleware($pipe);
$pipe = is_callable($pipeClass) ? $pipeClass : new $pipeClass;
} else {
$parameters = [];
}
// Call the middleware's handle method or invoke it
$resp = method_exists($pipe, 'handle')
? $pipe->handle($passable, $next, ...$parameters)
: $pipe($passable, $next);
if (!$resp instanceof BaseResponse && !is_string($resp)) {
$pipename = getCallableName($pipe);
throw new BaseException("$pipename must return a BaseResponse object or string");
}
return $resp;
};
};
}
/**
* Resolve middleware from a string definition.
*/
protected function resolveMiddleware(string|array $pipe)
{
// Split the pipe string to extract class and parameters
$parts = is_array($pipe) ? $pipe : explode(':', $pipe, 2);
$pipeClass = $parts[0];
$parameters = isset($parts[1]) ? explode(',', $parts[1]) : [];
Arguments
Eyika\Atom\Framework\Http\Request {#158}
Closure($request) {#132 …3}
/usr/home/basttyy/domains/api.sendmani.com/public_html/app/Http/Middlewares/EncryptCookies.php
protected array $except = [
'PHPSESSID', // Add other session-related cookies here
'XSRF-TOKEN', // Example: CSRF token cookie
];
/**
* Handle an incoming request.
*
* @param Request $request
* @param Closure $next
* @return BaseResponse
*/
public function handle(Request $request, Closure $next): BaseResponse
{
try {
// Decrypt incoming request cookies
$this->decryptCookies($request);
// Process the request and get the response
$response = $next($request);
// Ensure `$response` is a valid `BaseResponse` object
if (!$response instanceof BaseResponse) {
throw new \UnexpectedValueException('Middleware expects a BaseResponse instance.');
}
// Encrypt cookies in the response
$this->encryptCookies($response);
// Return the processed response
return $response;
} catch (\Exception $e) {
// logger()->error('Cookie decryption error:', [
// 'message' => $e->getMessage(),
// 'trace' => $e->getTraceAsString()
// ]);
throw $e;
}
}
Arguments
Eyika\Atom\Framework\Http\Request {#158}
/usr/home/basttyy/domains/api.sendmani.com/public_html/vendor/eyika/atom-framework/src/Http/Pipeline.php
* Get the callable that wraps middleware around the next handler.
* Create the closure chain for the pipeline.
*
* @return callable
*/
protected function carry(): callable
{
return function (Closure $next, string|array|callable $pipe): callable {
return function (Request $passable) use ($next, $pipe) {
if (is_string($pipe) || is_array($pipe)) {
// Resolve middleware class and parameters
[$pipeClass, $parameters] = $this->resolveMiddleware($pipe);
$pipe = is_callable($pipeClass) ? $pipeClass : new $pipeClass;
} else {
$parameters = [];
}
// Call the middleware's handle method or invoke it
$resp = method_exists($pipe, 'handle')
? $pipe->handle($passable, $next, ...$parameters)
: $pipe($passable, $next);
if (!$resp instanceof BaseResponse && !is_string($resp)) {
$pipename = getCallableName($pipe);
throw new BaseException("$pipename must return a BaseResponse object or string");
}
return $resp;
};
};
}
/**
* Resolve middleware from a string definition.
*/
protected function resolveMiddleware(string|array $pipe)
{
// Split the pipe string to extract class and parameters
$parts = is_array($pipe) ? $pipe : explode(':', $pipe, 2);
$pipeClass = $parts[0];
$parameters = isset($parts[1]) ? explode(',', $parts[1]) : [];
Arguments
Eyika\Atom\Framework\Http\Request {#158}
Closure(Request $passable) {#129 …4}
/usr/home/basttyy/domains/api.sendmani.com/public_html/vendor/eyika/atom-framework/src/Http/Middlewares/ShareErrorsFromSession.php
use Closure;
use Eyika\Atom\Framework\Http\BaseResponse;
use Eyika\Atom\Framework\Http\Request;
use Eyika\Atom\Framework\Http\Contracts\MiddlewareInterface;
use Eyika\Atom\Framework\Support\Facade\Blade;
class ShareErrorsFromSession implements MiddlewareInterface
{
/**
* Handle an incoming request.
*
*/
public function handle(Request $request, Closure $next): BaseResponse
{
// Share errors with the view
if ($request->hasSession()) {
$this->shareErrors($request);
}
return $next($request);
}
/**
* Share errors from the session with the view.
*
* @param Request $request
* @return void
*/
protected function shareErrors(Request $request): void
{
$session = $request->getSession();
if ($session->has(BaseResponse::REQUEST_ERRORS_KEY)) {
$errors = $session->get(BaseResponse::REQUEST_ERRORS_KEY);
$this->shareWithViews($errors);
$session->unset(BaseResponse::REQUEST_ERRORS_KEY);
}
if ($session->has(BaseResponse::REQUEST_VALIDATION_ERRORS_KEY)) {
$errors = $session->get(BaseResponse::REQUEST_VALIDATION_ERRORS_KEY);
$this->shareValidationWithViews($errors);
Arguments
Eyika\Atom\Framework\Http\Request {#158}
/usr/home/basttyy/domains/api.sendmani.com/public_html/vendor/eyika/atom-framework/src/Http/Pipeline.php
* Get the callable that wraps middleware around the next handler.
* Create the closure chain for the pipeline.
*
* @return callable
*/
protected function carry(): callable
{
return function (Closure $next, string|array|callable $pipe): callable {
return function (Request $passable) use ($next, $pipe) {
if (is_string($pipe) || is_array($pipe)) {
// Resolve middleware class and parameters
[$pipeClass, $parameters] = $this->resolveMiddleware($pipe);
$pipe = is_callable($pipeClass) ? $pipeClass : new $pipeClass;
} else {
$parameters = [];
}
// Call the middleware's handle method or invoke it
$resp = method_exists($pipe, 'handle')
? $pipe->handle($passable, $next, ...$parameters)
: $pipe($passable, $next);
if (!$resp instanceof BaseResponse && !is_string($resp)) {
$pipename = getCallableName($pipe);
throw new BaseException("$pipename must return a BaseResponse object or string");
}
return $resp;
};
};
}
/**
* Resolve middleware from a string definition.
*/
protected function resolveMiddleware(string|array $pipe)
{
// Split the pipe string to extract class and parameters
$parts = is_array($pipe) ? $pipe : explode(':', $pipe, 2);
$pipeClass = $parts[0];
$parameters = isset($parts[1]) ? explode(',', $parts[1]) : [];
Arguments
Eyika\Atom\Framework\Http\Request {#158}
Closure(Request $passable) {#128 …4}
/usr/home/basttyy/domains/api.sendmani.com/public_html/vendor/eyika/atom-framework/src/Http/Middlewares/StartSession.php
use Closure;
use Exception;
use Eyika\Atom\Framework\Http\BaseResponse;
use Eyika\Atom\Framework\Http\Request;
use Eyika\Atom\Framework\Http\Contracts\MiddlewareInterface;
use Eyika\Atom\Framework\Http\Session;
use Eyika\Atom\Framework\Support\Facade\Facade;
class StartSession implements MiddlewareInterface
{
/**
* Handle an incoming request.
*
*/
public function handle(Request $request, Closure $next): BaseResponse
{
if (strtolower($request->method()) !== "options") {
$this->startSession($request);
}
return $next($request);
}
/**
* Start the session for the request.
*
* @param Request $request
* @return void
*/
protected function startSession(Request $request)
{
if (!$request->hasSession()) {
$session = $this->createSession();
$request->setSession($session);
}
$request->getSession()->start();
}
/**
* Save the session data after the response has been sent.
Arguments
Eyika\Atom\Framework\Http\Request {#158}
/usr/home/basttyy/domains/api.sendmani.com/public_html/vendor/eyika/atom-framework/src/Http/Pipeline.php
* Get the callable that wraps middleware around the next handler.
* Create the closure chain for the pipeline.
*
* @return callable
*/
protected function carry(): callable
{
return function (Closure $next, string|array|callable $pipe): callable {
return function (Request $passable) use ($next, $pipe) {
if (is_string($pipe) || is_array($pipe)) {
// Resolve middleware class and parameters
[$pipeClass, $parameters] = $this->resolveMiddleware($pipe);
$pipe = is_callable($pipeClass) ? $pipeClass : new $pipeClass;
} else {
$parameters = [];
}
// Call the middleware's handle method or invoke it
$resp = method_exists($pipe, 'handle')
? $pipe->handle($passable, $next, ...$parameters)
: $pipe($passable, $next);
if (!$resp instanceof BaseResponse && !is_string($resp)) {
$pipename = getCallableName($pipe);
throw new BaseException("$pipename must return a BaseResponse object or string");
}
return $resp;
};
};
}
/**
* Resolve middleware from a string definition.
*/
protected function resolveMiddleware(string|array $pipe)
{
// Split the pipe string to extract class and parameters
$parts = is_array($pipe) ? $pipe : explode(':', $pipe, 2);
$pipeClass = $parts[0];
$parameters = isset($parts[1]) ? explode(',', $parts[1]) : [];
Arguments
Eyika\Atom\Framework\Http\Request {#158}
Closure(Request $passable) {#127 …4}
/usr/home/basttyy/domains/api.sendmani.com/public_html/vendor/eyika/atom-framework/src/Http/Middlewares/ServePublicAssets.php
}
$allowedOrigins = config('cors.allowed_origins', ['*']);
$origin = $request->headers('Origin');
$response = Response::setHeader("Content-Type", $mime, BaseResponse::STATUS_OK);
if ($allowedOrigins[0] === '*' || in_array($origin, $allowedOrigins)) {
$response->setHeader("Access-Control-Allow-Origin", '*');
$response->setHeader('Access-Control-Allow-Methods', "GET, OPTIONS");
$response->setHeader('Access-Control-Allow-Headers', "Content-Type");
}
return $response->body(file_get_contents($path));
}
return Response::html("File Not Found", BaseResponse::STATUS_NOT_FOUND);
}
}
return $next($request);
}
}
Arguments
Eyika\Atom\Framework\Http\Request {#158}
/usr/home/basttyy/domains/api.sendmani.com/public_html/vendor/eyika/atom-framework/src/Http/Pipeline.php
* Get the callable that wraps middleware around the next handler.
* Create the closure chain for the pipeline.
*
* @return callable
*/
protected function carry(): callable
{
return function (Closure $next, string|array|callable $pipe): callable {
return function (Request $passable) use ($next, $pipe) {
if (is_string($pipe) || is_array($pipe)) {
// Resolve middleware class and parameters
[$pipeClass, $parameters] = $this->resolveMiddleware($pipe);
$pipe = is_callable($pipeClass) ? $pipeClass : new $pipeClass;
} else {
$parameters = [];
}
// Call the middleware's handle method or invoke it
$resp = method_exists($pipe, 'handle')
? $pipe->handle($passable, $next, ...$parameters)
: $pipe($passable, $next);
if (!$resp instanceof BaseResponse && !is_string($resp)) {
$pipename = getCallableName($pipe);
throw new BaseException("$pipename must return a BaseResponse object or string");
}
return $resp;
};
};
}
/**
* Resolve middleware from a string definition.
*/
protected function resolveMiddleware(string|array $pipe)
{
// Split the pipe string to extract class and parameters
$parts = is_array($pipe) ? $pipe : explode(':', $pipe, 2);
$pipeClass = $parts[0];
$parameters = isset($parts[1]) ? explode(',', $parts[1]) : [];
Arguments
Eyika\Atom\Framework\Http\Request {#158}
Closure(Request $passable) {#126 …4}
/usr/home/basttyy/domains/api.sendmani.com/public_html/vendor/eyika/atom-framework/src/Http/Middlewares/ConvertEmptyStringsToNull.php
<?php
namespace Eyika\Atom\Framework\Http\Middlewares;
use Closure;
use Eyika\Atom\Framework\Http\BaseResponse;
use Eyika\Atom\Framework\Http\Request;
use Eyika\Atom\Framework\Http\Contracts\MiddlewareInterface;
class ConvertEmptyStringsToNull implements MiddlewareInterface
{
/**
* Handle an incoming request.
*
*/
public function handle(Request $request, Closure $next): BaseResponse
{
$this->clean($request);
return $next($request);
}
/**
* Clean the request's data by converting empty strings to null.
*
* @param Request $request
* @return void
*/
protected function clean(Request $request)
{
$input = $request->input();
$query = $request->query();
$cleanedInput = $this->convertEmptyStringsToNull($input);
$cleanedQuery = $this->convertEmptyStringsToNull($query);
$request->replaceInput($cleanedInput);
$request->replaceQuery($cleanedQuery);
}
Arguments
Eyika\Atom\Framework\Http\Request {#158}
/usr/home/basttyy/domains/api.sendmani.com/public_html/vendor/eyika/atom-framework/src/Http/Pipeline.php
* Get the callable that wraps middleware around the next handler.
* Create the closure chain for the pipeline.
*
* @return callable
*/
protected function carry(): callable
{
return function (Closure $next, string|array|callable $pipe): callable {
return function (Request $passable) use ($next, $pipe) {
if (is_string($pipe) || is_array($pipe)) {
// Resolve middleware class and parameters
[$pipeClass, $parameters] = $this->resolveMiddleware($pipe);
$pipe = is_callable($pipeClass) ? $pipeClass : new $pipeClass;
} else {
$parameters = [];
}
// Call the middleware's handle method or invoke it
$resp = method_exists($pipe, 'handle')
? $pipe->handle($passable, $next, ...$parameters)
: $pipe($passable, $next);
if (!$resp instanceof BaseResponse && !is_string($resp)) {
$pipename = getCallableName($pipe);
throw new BaseException("$pipename must return a BaseResponse object or string");
}
return $resp;
};
};
}
/**
* Resolve middleware from a string definition.
*/
protected function resolveMiddleware(string|array $pipe)
{
// Split the pipe string to extract class and parameters
$parts = is_array($pipe) ? $pipe : explode(':', $pipe, 2);
$pipeClass = $parts[0];
$parameters = isset($parts[1]) ? explode(',', $parts[1]) : [];
Arguments
Eyika\Atom\Framework\Http\Request {#158}
Closure(Request $passable) {#125 …4}
/usr/home/basttyy/domains/api.sendmani.com/public_html/app/Http/Middlewares/TrimStrings.php
namespace App\Http\Middlewares;
use Closure;
use Eyika\Atom\Framework\Http\BaseResponse;
use Eyika\Atom\Framework\Http\Request;
use Eyika\Atom\Framework\Http\Contracts\MiddlewareInterface;
class TrimStrings implements MiddlewareInterface
{
/**
* Handle an incoming request.
*
* @param Request $request
* @return mixed
*/
public function handle(Request $request, Closure $next): BaseResponse
{
$this->clean($request);
return $next($request);
}
/**
* Clean the request's data by trimming whitespace.
*
* @param Request $request
* @return void
*/
protected function clean(Request $request)
{
$input = $request->input();
$query = $request->query();
$cleanedInput = $this->trimArray($input);
$cleanedQuery = $this->trimArray($query);
$request->replaceInput($cleanedInput);
$request->replaceQuery($cleanedQuery);
}
Arguments
Eyika\Atom\Framework\Http\Request {#158}
/usr/home/basttyy/domains/api.sendmani.com/public_html/vendor/eyika/atom-framework/src/Http/Pipeline.php
* Get the callable that wraps middleware around the next handler.
* Create the closure chain for the pipeline.
*
* @return callable
*/
protected function carry(): callable
{
return function (Closure $next, string|array|callable $pipe): callable {
return function (Request $passable) use ($next, $pipe) {
if (is_string($pipe) || is_array($pipe)) {
// Resolve middleware class and parameters
[$pipeClass, $parameters] = $this->resolveMiddleware($pipe);
$pipe = is_callable($pipeClass) ? $pipeClass : new $pipeClass;
} else {
$parameters = [];
}
// Call the middleware's handle method or invoke it
$resp = method_exists($pipe, 'handle')
? $pipe->handle($passable, $next, ...$parameters)
: $pipe($passable, $next);
if (!$resp instanceof BaseResponse && !is_string($resp)) {
$pipename = getCallableName($pipe);
throw new BaseException("$pipename must return a BaseResponse object or string");
}
return $resp;
};
};
}
/**
* Resolve middleware from a string definition.
*/
protected function resolveMiddleware(string|array $pipe)
{
// Split the pipe string to extract class and parameters
$parts = is_array($pipe) ? $pipe : explode(':', $pipe, 2);
$pipeClass = $parts[0];
$parameters = isset($parts[1]) ? explode(',', $parts[1]) : [];
Arguments
Eyika\Atom\Framework\Http\Request {#158}
Closure(Request $passable) {#124 …4}
/usr/home/basttyy/domains/api.sendmani.com/public_html/vendor/eyika/atom-framework/src/Http/Middlewares/ValidatePostSize.php
use Eyika\Atom\Framework\Http\BaseResponse;
use Eyika\Atom\Framework\Http\Request;
use Eyika\Atom\Framework\Http\Contracts\MiddlewareInterface;
use Eyika\Atom\Framework\Http\Response;
use Eyika\Atom\Framework\Support\Facade\Response as FacadeResponse;
class ValidatePostSize implements MiddlewareInterface
{
/**
* Handle an incoming request.
*
*/
public function handle(Request $request, Closure $next): BaseResponse
{
// Check if the content length exceeds the post_max_size
if ($this->isRequestTooLarge($request)) {
return $this->handleRequestTooLarge($request);
}
return $next($request);
}
/**
* Determine if the request size exceeds the post_max_size.
*
* @param Request $request
* @return bool
*/
protected function isRequestTooLarge(Request $request)
{
$postMaxSize = $this->getPostMaxSize();
$contentLength = $request->server('CONTENT_LENGTH', 0);
return $postMaxSize > 0 && $contentLength > $postMaxSize;
}
/**
* Handle a request that is too large.
*
* @param Request $request
Arguments
Eyika\Atom\Framework\Http\Request {#158}
/usr/home/basttyy/domains/api.sendmani.com/public_html/vendor/eyika/atom-framework/src/Http/Pipeline.php
* Get the callable that wraps middleware around the next handler.
* Create the closure chain for the pipeline.
*
* @return callable
*/
protected function carry(): callable
{
return function (Closure $next, string|array|callable $pipe): callable {
return function (Request $passable) use ($next, $pipe) {
if (is_string($pipe) || is_array($pipe)) {
// Resolve middleware class and parameters
[$pipeClass, $parameters] = $this->resolveMiddleware($pipe);
$pipe = is_callable($pipeClass) ? $pipeClass : new $pipeClass;
} else {
$parameters = [];
}
// Call the middleware's handle method or invoke it
$resp = method_exists($pipe, 'handle')
? $pipe->handle($passable, $next, ...$parameters)
: $pipe($passable, $next);
if (!$resp instanceof BaseResponse && !is_string($resp)) {
$pipename = getCallableName($pipe);
throw new BaseException("$pipename must return a BaseResponse object or string");
}
return $resp;
};
};
}
/**
* Resolve middleware from a string definition.
*/
protected function resolveMiddleware(string|array $pipe)
{
// Split the pipe string to extract class and parameters
$parts = is_array($pipe) ? $pipe : explode(':', $pipe, 2);
$pipeClass = $parts[0];
$parameters = isset($parts[1]) ? explode(',', $parts[1]) : [];
Arguments
Eyika\Atom\Framework\Http\Request {#158}
Closure(Request $passable) {#123 …4}
/usr/home/basttyy/domains/api.sendmani.com/public_html/app/Http/Middlewares/PreventRequestsDuringMaintenance.php
public function __construct(array $except = [])
{
$this->except = $except;
}
/**
* Handle an incoming request.
*
*/
public function handle(Request $request, Closure $next): BaseResponse
{
// Check if the application is in maintenance mode
if ($this->isDownForMaintenance()) {
// If the request is not in the excepted URIs, block it
if (!$this->inExceptArray($request)) {
return $this->makeMaintenanceResponse();
}
}
return $next($request);
}
/**
* Determine if the application is in maintenance mode.
*
* @return bool
*/
protected function isDownForMaintenance()
{
// In Laravel, this would typically check for a file like 'storage/framework/down'
return file_exists(__DIR__ . '/storage/framework/maintainance.php');
}
/**
* Determine if the request has a URI that should pass through maintenance mode.
*
* @param Request $request
* @return bool
*/
protected function inExceptArray(Request $request)
Arguments
Eyika\Atom\Framework\Http\Request {#158}
/usr/home/basttyy/domains/api.sendmani.com/public_html/vendor/eyika/atom-framework/src/Http/Pipeline.php
* Get the callable that wraps middleware around the next handler.
* Create the closure chain for the pipeline.
*
* @return callable
*/
protected function carry(): callable
{
return function (Closure $next, string|array|callable $pipe): callable {
return function (Request $passable) use ($next, $pipe) {
if (is_string($pipe) || is_array($pipe)) {
// Resolve middleware class and parameters
[$pipeClass, $parameters] = $this->resolveMiddleware($pipe);
$pipe = is_callable($pipeClass) ? $pipeClass : new $pipeClass;
} else {
$parameters = [];
}
// Call the middleware's handle method or invoke it
$resp = method_exists($pipe, 'handle')
? $pipe->handle($passable, $next, ...$parameters)
: $pipe($passable, $next);
if (!$resp instanceof BaseResponse && !is_string($resp)) {
$pipename = getCallableName($pipe);
throw new BaseException("$pipename must return a BaseResponse object or string");
}
return $resp;
};
};
}
/**
* Resolve middleware from a string definition.
*/
protected function resolveMiddleware(string|array $pipe)
{
// Split the pipe string to extract class and parameters
$parts = is_array($pipe) ? $pipe : explode(':', $pipe, 2);
$pipeClass = $parts[0];
$parameters = isset($parts[1]) ? explode(',', $parts[1]) : [];
Arguments
Eyika\Atom\Framework\Http\Request {#158}
Closure(Request $passable) {#122 …4}
/usr/home/basttyy/domains/api.sendmani.com/public_html/app/Http/Middlewares/TrustProxies.php
// Default to X-Forwarded-For header
$this->headers = $headers ?? (Request::HEADER_X_FORWARDED_FOR | Request::HEADER_X_FORWARDED_HOST |
Request::HEADER_X_FORWARDED_PORT | Request::HEADER_X_FORWARDED_PROTO);
}
/**
* Handle an incoming request.
*
* @return mixed
*/
public function handle(Request $request, Closure $next): BaseResponse
{
// Trust the proxies configured for this application
$request->setTrustedProxies(
$this->proxies ?? ['127.0.0.1', 'localhost'], // Default to localhost if no proxies set
1
);
return $next($request);
}
/**
* Set the trusted proxies for this application.
*
* @param array|string|null $proxies
* @return $this
*/
public function setProxies($proxies)
{
$this->proxies = $proxies;
return $this;
}
/**
* Set the headers that should be used to detect proxies.
*
* @param int $headers
* @return $this
Arguments
Eyika\Atom\Framework\Http\Request {#158}
/usr/home/basttyy/domains/api.sendmani.com/public_html/vendor/eyika/atom-framework/src/Http/Pipeline.php
* Get the callable that wraps middleware around the next handler.
* Create the closure chain for the pipeline.
*
* @return callable
*/
protected function carry(): callable
{
return function (Closure $next, string|array|callable $pipe): callable {
return function (Request $passable) use ($next, $pipe) {
if (is_string($pipe) || is_array($pipe)) {
// Resolve middleware class and parameters
[$pipeClass, $parameters] = $this->resolveMiddleware($pipe);
$pipe = is_callable($pipeClass) ? $pipeClass : new $pipeClass;
} else {
$parameters = [];
}
// Call the middleware's handle method or invoke it
$resp = method_exists($pipe, 'handle')
? $pipe->handle($passable, $next, ...$parameters)
: $pipe($passable, $next);
if (!$resp instanceof BaseResponse && !is_string($resp)) {
$pipename = getCallableName($pipe);
throw new BaseException("$pipename must return a BaseResponse object or string");
}
return $resp;
};
};
}
/**
* Resolve middleware from a string definition.
*/
protected function resolveMiddleware(string|array $pipe)
{
// Split the pipe string to extract class and parameters
$parts = is_array($pipe) ? $pipe : explode(':', $pipe, 2);
$pipeClass = $parts[0];
$parameters = isset($parts[1]) ? explode(',', $parts[1]) : [];
Arguments
Eyika\Atom\Framework\Http\Request {#158}
Closure(Request $passable) {#121 …4}
/usr/home/basttyy/domains/api.sendmani.com/public_html/vendor/eyika/atom-framework/src/Http/Pipeline.php
return $this;
}
/**
* Run the pipeline with the given passable object.
*
* @return BaseResponse|string|bool
*/
public function run($passable)
{
$this->passable = $passable;
// Reduce the pipes to a single callable pipeline
$pipeline = array_reduce(
array_reverse($this->pipes),
$this->carry(),
$this->coreHandler
);
$resp = $pipeline($this->passable);
return $resp;
}
/**
* Get the callable that wraps middleware around the next handler.
* Create the closure chain for the pipeline.
*
* @return callable
*/
protected function carry(): callable
{
return function (Closure $next, string|array|callable $pipe): callable {
return function (Request $passable) use ($next, $pipe) {
if (is_string($pipe) || is_array($pipe)) {
// Resolve middleware class and parameters
[$pipeClass, $parameters] = $this->resolveMiddleware($pipe);
$pipe = is_callable($pipeClass) ? $pipeClass : new $pipeClass;
} else {
$parameters = [];
Arguments
Eyika\Atom\Framework\Http\Request {#158}
/usr/home/basttyy/domains/api.sendmani.com/public_html/vendor/eyika/atom-framework/src/Http/Route.php
$middlewares = array_merge(
static::$defaultMiddlewares,
static::findRouteMiddlewares($requestMethod, $requestUri)
);
// Core handler for the pipeline
$coreHandler = function ($request) use ($routeMatched, $requestMethod, $requestUri) {
// If no route matches, set up a 404 handler
if (!$routeMatched) {
return self::handleNotFound($request)->send();
}
$callback = self::$routes[$requestMethod][self::$currentRoute]['callback'];
return self::executeCallback($callback, $request, $request->route_params ?? []);
};
// Run the pipeline
$response = (new Pipeline())
->through($middlewares)
->then($coreHandler)
->run($request);
// Output the response
if ($response instanceof BaseResponse)
return $response->send();
elseif (is_string($response)) {
echo $response;
return true;
} else return true;
}
public static function route($name, $parameters = [])
{
foreach (self::$routes as $method => $routes) {
foreach ($routes as $route => $data) {
if ($data['name'] === $name) {
foreach ($parameters as $key => $value) {
$route = str_replace('$' . $key, $value, $route);
}
return empty($route) ? '/' : $route;
}
Arguments
Eyika\Atom\Framework\Http\Request {#158}
/usr/home/basttyy/domains/api.sendmani.com/public_html/vendor/eyika/atom-framework/src/Http/Server.php
public static function handle(): bool
{
try {
// ErrorHandler::register();
$request = static::$app->make('request');
static::$app->instance('request', $request);
if (preg_match('/^.*$/i', $request->requestUri())) {
//register controllers
if (!str_contains($request->pathInfo(), '/api') && !$request->wantsJson() && !$request->isXmlHttpRequest() && !$request->isOptions()) {
static::loadMiddlewares('web');
///TODO: load all default web middlewares
require_once base_path().'/routes/web.php';
} else {
Route::isApiRequest(true);
static::loadMiddlewares('api');
///TODO: load all default api middlewares
require_once base_path().'/routes/api.php';
}
$status = Route::dispatch($request);
if (!$request->isAssetRequest())
Route::storeCurrent();
return $status;
} else {
return false; // Let php bultin server serve
}
} catch (Throwable $e) {
/** @var ExceptionHandler $handler */
$handler = static::$app->make(ExceptionHandler::class);
return $handler->render($request, $e)->send();
}
}
private static function loadMiddlewares(string $type)
{
/** @var Kernel $kernel */
$kernel = static::$app->make(Kernel::class);
Arguments
Eyika\Atom\Framework\Http\Request {#158}
/usr/home/basttyy/domains/api.sendmani.com/public_html/public/index.php
|
*/
require_once __DIR__."/../vendor/eyika/atom-framework/src/helpers.php";
/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request using
| the application's HTTP kernel. Then, we will send the response back
| to this client's browser, allowing them to enjoy our application.
|
*/
try {
$app = require_once __DIR__.'/../bootstrap/app.php';
$server = new Server($app);
$server->handle();
} catch (\Exception $e) {
echo $e->getMessage();
}