API between two separate instances of Laravel
<p>I am trying to figure out a problem I have. I have 2 laravel setups on the same server, each are independent sites controlled via vhosts.</p>

<p>SiteA needs to act as an API to SiteB.  So within SiteA I set up an API by doing</p>

<pre><code>Route::group(['prefix' =&gt; 'api/v1'], function () {
    Route::post('postProject', array('as' =&gt; 'postProject', 'uses' =&gt; 'APIController@postProject'));
});
</code></pre>

<p>For now, the controller function is simply this</p>

<pre><code>public function postProject(Project $project)
{
    dd($project);
}
</code></pre>

<p>So within SiteB I want to call this API. As such, I set up a route which contains the project object (I have tried both get and post)</p>

<pre><code>Route::get('projects/{projects}/postProject', array('as' =&gt; 'projects.postProject', 'uses' =&gt; 'APIController@postProject'));
</code></pre>

<p>And this controller function does the following</p>

<pre><code>public function postProject($project)
{
    $client = new GuzzleHttp\Client();
    $req = $client-&gt;request('POST', 'http://localhost/api/v1/postProject', [
        'body' =&gt; $project,
        'headers' =&gt; [
            'Content-Type' =&gt; 'text/xml',
            'Content-Length' =&gt; strlen($project),
        ]
    ]);

    $output = $req-&gt;getBody()-&gt;getContents();

    return $output;
}
</code></pre>

<p>I have localhost as an example url so the real url wasnt exposed. The error siteB receives when making the post request is a 404 not found. If on siteA I set up a simple get function that returns something, siteB can execute this API call without any problem. The problem comes about when I am trying to post something from siteB to siteA.</p>

<p>Additionally, when I pass the $project object, is there any way to send over its related models as well? A $project has one to many relationships with a few other models, and ideally I would like to get the related data over.</p>