Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

princearora's avatar

Unexpected behavior of Laravel on Curl request

I have two projects Project A & Project B .There's one point where i want to both projects to communicate So i did Curl Request from project B to Project A . I made a Api in Project A for project B . The Api works fine i tested in Postman . So i thought A Curl request from project B to project A do the job .

project B Curl request

        $body=['name'=>'Prince'];
        curl_setopt($ch, CURLOPT_URL,"projectA/emsapi/nextmla/notifier");
        curl_setopt($ch, CURLOPT_POST, 1);
       
        curl_setopt($ch, CURLOPT_POSTFIELDS, 
                 http_build_query($body));
        // curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $output = curl_exec ($ch);
        curl_close ($ch);
        return $output;

    }  ```

Project A Api request handler Method

``` public function nextmlaNotify(){
    
        return \DB::getDatabaseName();  
        
    }  ```

I noticed a weird thing on curl request Project showed the name of database of Project B 
so any one know why this is happening ...????
0 likes
1 reply
aurawindsurfing's avatar

Just call that function directly or from command line curl or from postman and see what you get.

Please or to participate in this conversation.