Code Monkey home page Code Monkey logo

Comments (3)

reinink avatar reinink commented on September 13, 2024

Okay, so I've just messed around with how you could manually create an instance of the Request object, and it can be done like so:

use Symfony\Component\HttpFoundation\Request;

$request = new Request(
    [
        'w' => (string) 100,
    ],
    [],
    [],
    [],
    [],
    [
        'REQUEST_URI' => '/rose.jpg'
    ]
);

Just a little messy, so a factory helper is probably smart.

from glide.

reinink avatar reinink commented on September 13, 2024

The other option is that we still allow the sending of the $filename and $params values to the method, and those methods just convert them into a Request object behind the scenes.

This sort of comes down to what is more likely. Will people prefer to send these in manually, or will they prefer to simply send an instance of the Request object? I sort of feel like the prior (two parameters) if they are using Glide within an app, and the later (request object) if they are using Glide as it's own image server.

# Option 1 (most likely used in image server)
public function outputImage(Request $request)
public function getImageResponse(Request $request)
public function makeImage(Request $request)

# Option 2 (most likely used within an app)
public function outputImage($filename, Array $params)
public function getImageResponse($filename, Array $params)
public function makeImage($filename, Array $params)

Would it be terrible if these methods accepted both options?

  1. If the first parameter is an instance of Request, use it and ignore the second parameter.
  2. If the first parameter is a string, use it with the second parameter (array) to create a new Request instance.

from glide.

reinink avatar reinink commented on September 13, 2024

Done: cfc837d

Ended up allowing three methods to accept either an instance of Request, or a string and array combination, which is automatically converted into a Request instance.

from glide.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.