Is there any clear instructions on deploying slim in a shared host because i have a go daddy cpanel shared host and i have tried every available instructions and all of them failed knowing that i have a ssh access and already installed it through composer
( the app is working on the local machine )
- Slim 3.3.0 on Shared Hosting
- Using Composer with shared hosting (written by one of the Slim leads)
The key is often to mimic the directory structure locally that you are forced to use in the shared environment. As we discussed in your other thread, sometimes shared hosts don’t allow you access above your “public” folder, which can be an issue if you didn’t develop the app that way. Not a big one to change though.
If you can describe to use the directory structure of your app as well as the directory structure of your hosting environment I’m sure we can get you up and running.
the directory structuer of the cpanel : http://imgur.com/a/mtiZj
the directory structuer of my app : http://imgur.com/a/gIhbZ
Okay. So you will need to change the directory structure of your app a bit to match. It looks like the root web directory of your site is the public_html
folder. I assume for a typical site on that host that is where you would put your index.php
or index.html
file, correct?
So in your app, you will need to rename the public
folder to be public_html
and adjust the webserver you are running locally to point to that new location. Then, when you upload your files, your .htaccess
and index.php
files that were previously in your public
folder will now go into the public_html
folder.
Your other folders and files src/
, vendor/
, composer.json
, composer.lock
etc will live in the top level directory you posted… so src/
will be right alongside public_html/
and tmp/
.
Then you should be good to go. Does that make sense? If it still doesn’t work, error logs might be helpful.
It’s working smoothly , i am really grateful and thankful to you
Hi,
Please help me.
few days ago… i ame looking for solution about how to deploy my slim api on shared hosting.
please how to do ?
i use the same code from this tuto : https://youtu.be/DHUxnUX7Y2Y
does it have anything to do with my questions?
seriously…
@rollano what have you tried so far and what errors are you seeing?
Hi
Thank to answer me
i have a mysql database
the files are on my serveur (real one note a local)
i have some folder in the public_html folder
public_html
.api_rest
…ipoomsae_1
…index.php
…composer.lock
…composer.json
…htaccess
…vendor
…src
…routes
…articles.php
…config
…db.php
the error_log file for articles.php : PHP Fatal error: Class ‘Slim\App’ not found in /home/taekwond/public_html/APP/api_rest/ipoomsae_1/src/routes/articles.php on line 5
i don’t know what is wrong
error on chrome : HTTP ERROR 500
Looking at the error log, what does the referenced articles.php have on lines 1-5?
here is
line 1 to 11
Line 1 : <?php
Line 2 : use \Psr\Http\Message\ServerRequestInterface as Request;
line 3 : use \Psr\Http\Message\ResponseInterface as Response;
ligne 5 : $app = new \Slim\App;
line 9-10-11 :
$app->options(’/{routes:.+}’, function ($request, $response, $args) {
return $response;
});
Are you not creating your App within index.php?
No functions are in articles.php
…
I change a bit my structure
|__app (Folder)
|…|__api_rest (Folder)
|… …|__projectName (Folder)
|… … …|__src (Folder)
|… … … …|__config (Folder)
|… … … … … |__db.php (File)
|… … … … |__routes (Folder)
|… … … … … |__articles.php (File)
|… … …|__vendor (Folder)
|
|__public_html
|… | __ index_Api_projectName.php (index file)
|… | __ error_log
|… | __ .htaccess
Postman => 200 Ok (but nothing)
error log => [06-Apr-2018 11:12:25 UTC] PHP Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/taekwond/public_html/include/config.php on line 13
db. php content
// Connect
public function connect(){
$mysql_connect_str = “mysql:host=$this->dbhost;dbname=$this->dbname”;
$dbConnection = new PDO($mysql_connect_str, $this->dbuser, $this->dbpass);
$dbConnection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
return $dbConnection;
}
Hi
i find my error.
i delete : $app = new Slim(); from articles
and now it worked
Hello, i have the same issue as if you. can i have a look of your index.php (or you changed the name to index_Api_projectName.php) the file? cause i have basically followed the same tutorial as if yours
Hi friend,
Yes i have change the name of my index. As you Know index.php is my root files of my web site.