Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7411503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:23:49+00:00 2026-05-29T06:23:49+00:00

I have got script which generates some graphic and returns it as a result,

  • 0

I have got script which generates some graphic and returns it as a result, also it caches this graphics etc.

I use symfony2 and in a controller I need to invoke this script, for now I use this function, to invoke my php script:

        private function http_post($url, $data)
            {
                $data_url = http_build_query ($data);
                $data_len = strlen ($data_url);

                return array ('content'=>file_get_contents ($url, false, stream_context_create (array ('http'=>array ('method'=>'POST'
                        , 'header'=>"Connection: close\r\nContent-Length: $data_len\r\nContent-Type: application/x-www-form-urlencoded\r\n"
                        , 'content'=>$data_url
                        ))))
                    , 'headers'=>$http_response_header
                    );
            } 

I think this way isn’t the best and as I remember well file_get_contents is pretty slow?
So my question: is it good way to send POST to this script via “http_post”? If not, than what would be better?

EDIT: I don’t want to have this script in a controller, so no include solutions please :).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T06:23:49+00:00Added an answer on May 29, 2026 at 6:23 am

    If you wish to implement the image generator as a controller, you would just return the response as normal: return new Response($generated_image);.

    So this could be your controller:

    namespace Acme\MyBundle\Controller;
    use Symfony\Component\HttpFoundation\Response;
    
    class ImageGeneratorController
    {
        public function generateAction($parameters)
        {
          //Generate an image using parameters and store it in $image
          $image = ....
    
          return new Response($image);
        }
    }
    

    Then, you can call your image generator from any controller using forward()

    public function indexActionInAnotherController($name)
    {
        $response = $this->forward('AcmeMyBundle:ImageGenerator:generate', array(
            'name'  => $name,
            'color' => 'green'
        ));
    
        // further modify the response or return it directly
    
        return $response;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have got a python script which is creating an ODBC connection. The ODBC
I have got some code to load an assembly and get all types, which
I have a Jquery Script which is depenedent on this Script Sort.js . Can
i have this script which i will post absolutely unmodified: <? chdir(data); $files =
I have got a demo script that lets me authorize with my app and
I've got a file whose format I'm altering via a python script. I have
We have got loads of options for php + MySQL + Apache combo... Which
I have this hidden link, which is needed for other purposes: <span id=notitle style=display:
Discount 's configure.sh script generates some dynamic comments at the start of the config.h
For some reason the script below is not working. This is the code I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.