Setting up a SLIM app via digital ocean on laravel forge using LEMP stack?

Published 2 months ago by SomeT

You can set up a digital ocean workflow quite easily in forge for laravel. When I do the same in SLIM it does not work, is there something I am missing to get this working? Would I have to set it up as a custom VPN instead? Preferably need to use LEMP stack as well.

Best Answer (As Selected By SomeT)
bobbybouwmann

You can just use the regular way of setting up a project. So Add site. Under Project Type you can select "General PHP / Laravel" and set the Web Directory to "/public". After that you can choose the correct repository and it should be up and running ;)

You of course need to make sure all other dependencies are available and all config is set!

I just installed it in less than a minute on this subdomain: http://slim.markdownmail.com/

bobbybouwmann

You can just use the regular way of setting up a project. So Add site. Under Project Type you can select "General PHP / Laravel" and set the Web Directory to "/public". After that you can choose the correct repository and it should be up and running ;)

You of course need to make sure all other dependencies are available and all config is set!

I just installed it in less than a minute on this subdomain: http://slim.markdownmail.com/

SomeT

In Laravel forge there is no option for add site only add server. I think add site is after you added the server, but do you just do it as digital ocean in this case? Additionally would that not set it up as a LEMP server when what I want is a LAMP server. If you could do more in depth details for me on setup be much appreciated or a video recording or something.

bobbybouwmann

Yes, you first need the server.

You can do the normal setup with a server using Forge. It will setup a server with PHP, nginx and everything else configured. After that you can add a site and install slim. That should be it ;)

I don't have the time to record a video for you...

SomeT

Ok no worries, I have done this, I followed the hello world tutorial on the slim site I get the following: No input file specified.

locally using laragon I get:

Warning: require(/vendor/autoload.php): failed to open stream: No such file or directory in C:\laragon\www\myapp\Slim\src\public\index.php on line 5

Fatal error: require(): Failed opening required '/vendor/autoload.php' (include_path='.;C:/laragon/etc/php/pear') in C:\laragon\www\myapp\Slim\src\public\index.php on line 5

my code of index.php is:


<?php
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;

require '../vendor/autoload.php';

$app = new \Slim\App;
$app->get('/hello/{name}', function (Request $request, Response $response, array $args) {
    $name = $args['name'];
    $response->getBody()->write("Hello, $name");

    return $response;
});
$app->run();.

SomeT

Update got it working locally by putting the full path to autoload.php in vendor folder.

As for publically I have no idea... the public environment would have been the one set up by forge.

SomeT

Current directory setup: https://gyazo.com/033a8f391318b5a92cf8158f0009f003]

So I now know .. means one up the question is how do I go a few more folders up in a html url? .... = 2 folders up? I tried to google that question without much luck.

bobbybouwmann

I cloned this repository and put that online: https://github.com/slimphp/Slim-Skeleton

Just as a starter kit ;)

SomeT

Additionally not sure if 'no input file specified' on the live server is a completely different error to this?

Cronix
Cronix
2 months ago (737,880 XP)

The "public" dir really shouldn't be in the "src" dir. Check the github link @bobbybouwmann showed in his last post for the correct structure.

And in forge, the public dir should be the "web directory"

Edit: you shouldn't mark it as "solved" until you actually get it working. Most people don't look in solved threads unless they have the same problem and are looking for the fix, so they won't see your additional questions...

SomeT

Yeah sorry I kinda got half of it working, why I posted it as solved.

SomeT

Got it working with the skeleton app, however as I am just starting out with Slim framework, what are the key differences between https://github.com/slimphp/Slim-Skeleton and https://github.com/slimphp/Slim/tree/3.x/Slim is there anything vital the skeleton app is missing?

bobbybouwmann

slimphp is the framework, but slim-skeleton is just a starting setup for your application. Just like laravel/framework is the framework itself but laravel/laravel is the project with some setup that includes the framework ;)

Cronix
Cronix
2 months ago (737,880 XP)

Why wouldn't you be searching the slim forums/docs? Slim has nothing at all do to with laravel. http://help.slimframework.com/

SomeT

So slim-skeleton still contains the framework still right? @bobbybouwmann

And sorry I did ask this elsewhere but no response and I thought as the conversation was on this subject it would be ok to carry on discussing it.

bobbybouwmann

@SomeT Yes, the skeleton project pulls in the framework. You can see that in the composer.json file ;)

Please sign in or create an account to participate in this conversation.