I'm currently in the investigation stage of using CakePHP (2.x in particular). I noticed that on the deployment docs I need to set the document root accordingly in httpd.conf, unfortunately for this project I don't have access to httpd.conf nor any directories below the given webroot.
Given that, my two questions are:
1. Is it possible to still run CakePHP without being able to set the document root?
2. Are there any potential downsides in doing this?
Absolutely, you can use CakePHP in any subdirectory. The only thing you may find useful is the RewriteBase directive, which I think is well explained here: How does RewriteBase work in .htaccess
The one other small problem I've noted is that some CakePHP plugins out there do assume a root directory :( which is unfortunate, and I've had to append Router::url("/") when I see those.
Other than that, you should have no problem running CakePHP on a subdirectory.
Related
I have a CakePHP installation with multiple apps that has this structure:
/cake-1.3.10
/cake-2.3.0
/apps/app 1
/apps/app 2
/...
/apps/app N
/apps/_shared/Cake_v1/Component
/apps/_shared/Cake_v1/Model
/apps/_shared/Cake_v2/Component
/apps/_shared/Cake_v2/Model
So what happens here is that all the apps grab the v1.3 or v2.3 cores (depending on which version of the framework they use). In addition, I have some Components and Models that all the apps share. Each app loads those from the _shared folder depending on its version.
Until here all works great.
Now, I would like to do the same for the database configuration. Each app has its own /config/database.php file. How would I go about making it so ALL apps share the same database.php file? Actually I would have 2 database.php files, one per version, since they're different (like with Components and Models). But I'm not sure what exactly I need to change to accomplish that.
I don't see that there is easy CakePHP way. You have to modify /lib/Cake/Model/ConnectionManager.php . In version 2.3 on line 69 there is
include_once APP . 'Config' . DS . 'database.php';
I don't see there any code that allows the configuration. It looks hardcoded.
More elegant way is that you make symbolic links as #Kai mentioned. Then you can upgrade CakePHP without having to remember about your little hack.
A site I'm currently managing has Drupal 7.17 on it. I'm noticing the following files in the root of the website:
install.php
CHANGELOG.txt
INSTALL.txt
INSTALL.mysql.txt
INSTALL.pgsql.txt
LICENSE.txt
MAINTAINERS.txt
UPGRADE.txt
Researching this, tells me that as of Drupal 7.16, they fixed a security issue that would allow arbitrary code to run in install.php that would allow the re-installation of Drupal that someone could run. But basically, I am wondering if any of these files (if left in the server root) could cause problems in Drupal 7.17? Do I have to remove these files for security reasons? Or is this no longer a security risk whatsoever in Drupal 7.17?
I understand that we shouldn't remove the upgrade.php file, but just curious on the rest of these files.
Thanks, and this is probably a dumb question, but just felt the need to ask anyways. Usually I remove these files when I install software on websites, but not sure how Drupal uses and/or misuses these files.
Based on the document “Finalize the upgrade” (which applies to both upgrades and installations) from the Drupal handbook:
The last step in an upgrade is to delete or move the following files from your site:
install.php
CHANGELOG.txt
INSTALL.txt
INSTALL.mysql.txt
INSTALL.pgsql.txt
INSTALL.sqlite.txt
LICENSE.txt
MAINTAINERS.txt
UPGRADE.txt
Just to make that clear: the only PHP file to delete is "install.php" (i.e. be sure to leave "upgrade.php" and all other PHP files). And when you delete the TXT files, be sure to keep "robots.txt" since it is used by search engines.
You shouldn't delete any files. If you really wanted to, you could delete various txt files. A better solution if you are afraid of security is to not let the files be accessed through the web server. Drupal only use the index.php file for serving content.
I would love to hear an update and more recent thoughts on this question, and here is why.....
I was just working with a newly updated Drupal site to Drupal 8.9.20 running the Open Social distribution as a logged-in user with no admin privileges. This is my ACTIVE PRODUCTION site!
I deleted a node (News Article) I was trying to embed from a website that refuses to connect on some of their metadata ie: image #1, and after submitting on the delete link, the browser switched to install.php, which as you know sites in the document root.
I was of course shocked to see this and after considering the even innocent response a user might get that lead them to reinstall THEIR App, this could be very dangerous, of course.
So, since the last reply on this references Drupal versions from 2014, I was
just wondering your thoughts in this day and age on what are the latest recommendations!
Thanks
I am using CakePHP 2.2 and I will probably need to use SMTP with TTL which is only available at CakePHP 2.3.0.
The additions for this new feature are documented here:
https://github.com/cakephp/cakephp/pull/734
And i was wondering where should I add this code in my CakePHP project as I guess the core folders should stay untouched.
Could I do it using the app\lib folder? In that case, how should I add the content? Do I need to follow any structure? How Cake would detect it?
Thanks.
Just follow the CakePHP Migration guide and update to 2.3.
Honestly, I didn't even read through the migration guide, I just swapped into 2.3 and everything has just worked. It doesn't appear that there are many changes to existing code - just improvements / additions, so you'll likely not have to do any code modification.
I like to keep my versions of Cake separate (see advanced installation), but if you're on the normal install, just replace the files within /lib/Cake/ with the new versions files.
Does anyone know why my "generate.py build" works just fine, but when I run "generate.py source" it cannot find:
"http://localhost/qooxdoo-1.6-sdk/framework/source/class/qx/Bootstrap.js?nocache=0.39702596611879537"
this is because it should be:
http://localhost/*username/*qooxdoo-1.6-sdk/framework/source/class/qx/Bootstrap.js?nocache=0.39702596611879537"
but I cannot find where this setting is.
I tried editing the variable "QOOXDOO_PATH" in config.json, but that didn't seem to work.
Please help, thanks!
You cannot just run a source version through a web server without taking some precautions. The generator generates relative URIs which work nicely on the file-system level (i.e. when you open your app with the file:// protocol in the browser). But relative paths are not stable under a web server.
As a simple example, if you have a file /foo/bar/baz/index.html which references ../../bong/other.png, other.png will be found on the file system in /foo/bong/. But if you have a web server on this machine with a DocumentRoot of /foo/bar/, the URL to load the index.html is http://localhost/baz/index.html and the above relative reference is overstepping the web server's root and will cause an error.
One way to make this work is to make sure that your web server's DocumentRoot is above the root directories of all involved libraries your app is using (i.e. your app itself, the qooxdoo SDK, other lib/contribs you are using, etc.). See here for a fuller explanation.
Don't fiddle with QOOXDOO_PATH, as this is necessary to find the framework classes and build your app in the first place.
make sure you use a relative path when setting the source location:
../../../../../../../../home/*user*/qooxdoo-1.6-sdk
if you are working with perl, I would recommend using the the mojo bindings http://qooxdoo.org/contrib/project/rpcperl-mojo they allow you to run both the build and the source version through the built in web server, taking care of all the path magic.
I am a total dummy to programming so pls understand if my question might sound dumb.
I successfully baked a cakephp website using "cake bake" command. I baked it in my webroot (C:\wamp\www) along with my core CakePHP. Then I decided to transfer my core CakePHP to another location so to prevent from making any accidental changes. When I tried to run the website after the core cakePHP was transfered I got 3 errors:
Warning: include(cake\bootstrap.php) [function.include]: failed to open stream: No such file or directory in C:\wamp\www\cakeauth\webroot\index.php on line 76
Warning: include() [function.include]: Failed opening 'cake\bootstrap.php' for inclusion (include_path='C:\wamp\www\cakephp\cakephp_1.3.8;C:\wamp\www\cakeauth\;.;C:\php\pear') in C:\wamp\www\cakeauth\webroot\index.php on line 76
Fatal error: CakePHP core could not be found. Check the value of CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php. It should point to the directory containing your \cake core directory and your \vendors root directory. in C:\wamp\www\cakeauth\webroot\index.php on line 77
My question is, how come the "baked php site" still need the core CakePHP? I think it should be stand alone. What if I am gonna transfer the site to another server / computer, do I have to transfer the core CakePHP along with it? I wanna if there's any work around for this. Pls help...
The bake console command only generates the stub classes for your MVC structure. It still depends on the cake folder for the library support.
You can still move your cake folder around, but you need to specify the new location when you do move it.
You can also run multiple cake applications that depend on the same library.
Have a look at the advanced installation options in the bakery : http://book.cakephp.org/view/915/Advanced-Installation
The Cake Bake command only creates the default models, controllers and views based on your database structure, it does not build an out-of-the-box application, like a compiler.
Your app still requires the CakePHP core files to be available to work, this is true with all frameworks, you cane however run multiple apps with their own app folder off one cake folder. You just need to update all the include paths in index.php to get yourself started.