Namespace everything. You can keep it all inside the same application then. There is no point in maintaining 2 code bases because you will have to repeat your business logic in 2 places.
In your routes, then you can then do this
Route::controller('user', 'UserController');
Route::group(['prefix' => 'api', 'namespace' => 'Api'], function() {
Route::controller('user', 'Api\UserController');
});
Also, don't write your business logic in your controllers. Use commands (known as jobs in Laravel 5.1) and repositories instead.
Pretend you have a Create User feature. Then you will have a corresponding Command/Job class for that.
namespace App\Jobs;
use App\Repositories\UserRepository;
use App\Jobs\Job;
use Illuminate\Contracts\Mail\Mailer;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Bus\SelfHandling;
use Illuminate\Contracts\Queue\ShouldQueue;
class CreateUser extends Job implements SelfHandling, ShouldQueue
{
use InteractsWithQueue, SerializesModels;
protected $user;
public function __construct(UserRepository $user)
{
$this->user = $user;
}
public function handle(Mailer $mailer)
{
// logic to create user
}
}
Which you will use in your UserController
public function postCreateUser()
{
// validate request
$this->dispatch(new CreateUser($inputData));
// return view
}
and then your Api\UserController
public function postCreateUser()
{
// validate request
$this->dispatch(new CreateUser($inputData));
// return JSON output
}