I made a project in cakephp 3.0 which I want to put on a shared hosting server.
Cakephp documentation have given the solution for the previous versions here http://book.cakephp.org/2.0/en/installation/advanced-installation.html where directory structure was different than the new one.
In the older version for doing an advance installation on a shared hosting server the whole project is splitted into 3 parts
and then those path are written in the .htaccess file for running the project.
In the new version app directory has become src, webroot is as it is but I couldn't find the lib directory for the installation.
Can anyone help me that how to go about it in its latest version?
Installing CakePHP Go to the folder where wamp is located for windows users and in www/ folder, create a folder cakephp4/. For Linux users, create the folder var/www/html/ and then create folder cakephp4/. cakephp4/ is the folder where we are going to install CakePHP.
The way I got this working was to structure the directories on the shared host like so:
/home/username/public_html/
// webroot contents goes here
css/
img/
js/
.htaccess
index.php
/home/username/mycakeapp/
// necessary app directories go here
/config
/logs
/plugins
/src
/tmp
/vendor
Then I changed WWW_ROOT
in mycakeapp/config/paths.php
on line 52:
define('WWW_ROOT', '/home/username/public_html/' . DS);
Finally, I had to change the path to bootstrap.php
defined in the webroot index.php
file on line 28 (located at /home/username/public_html/index.php
):
require '/home/username/mycakeapp/config/bootstrap.php';
A small update to the answer of @jjz.
Is your structure is:
/home/username/public_html (with webroot contents)
/home/username/mycakeapp (installed cakephp 3 app)
Change /home/username/public_html/index.php:
FROM: require dirname(__DIR__) . '/config/bootstrap.php';
TO: require dirname(__DIR__) . '/mycakeapp/config/bootstrap.php';
Change /home/username/mycakeapp/config/paths.php:
FROM: define('WWW_ROOT', ROOT . DS . 'webroot' . DS);
TO: define('WWW_ROOT', realpath(ROOT . DS . '../public_html' . DS));
This way your app will be more portable, it does not depend on being in /home/username.
Given by the default configuration of CakePHP3, I've found this method to be least disruptive.
Assumptions:
Steps:
That's all!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With