Visitar URL original
Help Wanted : SlimFramework 3 · Issue #311 · php-pm/php-pm · GitHub
Skip to content

Help Wanted : SlimFramework 3 #311

Open

Description

@VincentSurelle

Hi,

I'm trying to build a SlimFramework Bridge for PPM. For now I'm able to run it, but I'm having issues with caching.

First, I don't know how to manage request caching. If I run a request that could change over the time, I will always have the same result.

Next is for JWT protected requests. If I run a protected request without my token in the header. I obviously get a 401 Unauthorized response. So I run another request on the same path but, this time, with a JWT, I get the ressources I asked for. For now it's absolutely legit.
Let's run a third request, still on the same path but without JWT. I expect another 401 error. But no, I get the ressource I asked for, without authentication.

Can someone give help to destroy data between requests ?

Obviously when finished I'll push it to PPM Github

Activity

  1. VincentSurelle commented on Dec 18, 2017

    @VincentSurelle
    Author

    Today I'm having something like this (not finished). Which work well but I'm still facing the same (cache?) issue.

    <?php
    
    namespace Boostrap;
    
    use Interop\Http\Server\RequestHandlerInterface;
    use PHPPM\Bootstraps\ApplicationEnvironmentAwareInterface;
    use PHPPM\Bootstraps\BootstrapInterface;
    use PHPPM\Bootstraps\HooksInterface;
    use PHPPM\Bootstraps\RequestClassProviderInterface;
    use Psr\Http\Message\ServerRequestInterface;
    use Slim\App;
    use Slim\Container;
    use Slim\Http\Response;
    
    class SlimBootstrap implements ApplicationEnvironmentAwareInterface, RequestHandlerInterface
    {
        protected $appenv;
        protected $debug = false;
    
        /**
         * @var App
         */
        protected $app;
    
        public function initialize($appenv, $debug)
        {
            $this->appenv = $appenv;
            $this->debug = $debug;
    
            $app = new App($this->getContainer());
    
            include 'app/routes.php';
            include 'app/middlewares.php';
    
            $this->app = $app;
        }
    
        private function getContainer()
        {
            $logger = function($container) {
                $logger = new Logger(getenv('APP_NAME') ?? 'Slim');
    
                $logger->pushHandler(new RotatingFileHandler('/log.txt'));
    
                return $logger;
            };
    
            return new Container([
                'settings' => [
                    'displayErrorDetails' => ($this->appenv !== 'prod')
                ],
                'logger' => $logger
            ]);
        }
    
        public function handle(ServerRequestInterface $request)
        {
            $response = $this->app->process(
                $request,
                new Response());
            return $response;
        }
    }

    For testing, I tried unsetting $app and rebuild it on every request but it doesn't seem to do anything.
    I really don't know where to look at to remove request caching across multiple clients.

  2. andig commented on Jan 9, 2018

    @andig
    Contributor

    It might help asking at the Slim repo/forums.

  3. code-runner-2017 commented on Jan 11, 2018

    @code-runner-2017

    Slim 3 supports PSR-7, right?
    I found this: https://github.com/php-pm/php-pm-psr7, marked as obsolete because "PSR-7 compatibility is now built into php-pm directly".
    As far as I understand, it should be possible to use Slim directly with PHP-PM, but I couldn't find any reference in the documentation.

    Anyone successful running Slim 3 with PHP-PM without any bridge?

  4. andig commented on Jan 11, 2018

    @andig
    Contributor

    Slim 3 supports PSR-7, right?

    If it does we still need a way to pass the request into the framework. The base repo has 2 middleware bridges for that purpose but- looking at the code above- interacting with Slim takes more and we'll require Slim kx to implement it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions