document-root

Defining the document root directory as the ROOT_PATH

泄露秘密 提交于 2019-12-12 05:24:06
问题 I use some constants to define paths to specific directories on a website that I'm building, like this: define("ROOT_PATH", "http://website.com/"); define("IMAGES_DIR", ROOT_PATH . "images/"); and I usually use them like this: echo "<img src='" . IMAGES_DIR . "some_image.jpg' />"; now I want to know if there is any difference between define("ROOT_PATH", "http://website.com/"); and define("ROOT_PATH", "/home/username/public_html/"); and which one of them should I use? And why? 回答1: You can't

Define a rootpath in php

倖福魔咒の 提交于 2019-12-12 04:58:29
问题 I read up on how to define a rootpath constant that is useable in all subpages when using a single page application. Now my question is, how can i use the basepath in my scripts i point to in my form actions? My problem is that i want to use a relative path, compared to where the script is located, in the "action" scripts so that the path will work no matter from where that file is called. I tried using dirname(__FILE__) but as i use files in parent directories some levels up i ended up with

PHP - Smarter Files Referencing

淺唱寂寞╮ 提交于 2019-12-12 01:12:42
问题 I have some simple PHP scripts that helps me with small tasks on each of my servers. I run it via the CLI only, since not all my servers have Apache, but I install PHP on all. I'd like to make it portable, at any time. Here's my scripting scheme: dir_libs/top.php (top.php references all my classes and functions) dir_logs/ (holds logs I may create) runstats.php (this is what I initialize from CL) Here's what I have done on one of my servers: runstats.php <?php require('/home/myuser/public_html

Is it prefered to use $_SERVER['DOCUMENT_ROOT'] in the website?

本小妞迷上赌 提交于 2019-12-11 04:58:44
问题 Do you think it is preferred to use $_SERVER['DOCUMENT_ROOT'] in website's include statements? Is it supported everywhere without any problem? 回答1: Many frameworks use dirname(__FILE__) to work out the application path based on a known file, usually the index.php In the Zend Framework, they use the following to define the application path, which is then used everywhere in the app: define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'); 回答2: I personally prefer relative

PHP file_exists not working outside document root

廉价感情. 提交于 2019-12-11 01:09:31
问题 I have the following directory structure where the Document Root is pointed to /var/www/html/public: /application /application/controllers /public (Document Root) I am trying to use the following code to check if a file exists inside a file in the /public directory (working on local setup, but not on live server) <?php if (file_exists('../application/controllers/TestController.php')) { /* do something */ } Could there be something in the Apache config file the I need to add? I am not sure

Path of current PHP script relative to document root

倾然丶 夕夏残阳落幕 提交于 2019-12-06 23:11:24
问题 TL;DR : What alternatives to the last code sample on this page are there when trying to use relative links on pages included with PHP's include command? I'm trying to include() a file that links to a .css document, the problem is that I need to include this file from multiple (different) directories. My directory structure looks somewhat like this: www ├── (getpath.php) │ ├── css │ └── style.css ├── php │ └── header.php └── content ├── index.php └── posts └── index.php (I'm including header

PHP - Document_Root vs Sub-Domains

喜欢而已 提交于 2019-12-06 15:50:50
I have the following code in my configuration file to establish the root path which is then used throughout the application: define('ROOT_PATH', $_SERVER['DOCUMENT_ROOT'].'/MyAppFolder/'); The problem is that it does not seem to work with sub domains. if I try to include my configuration file into a PHP file that is on the sub domain, naturally, I get an error. How can I get around this problem? How can I establish a root path that allows sub domains? I've never done this before so I haven't a clue how to go about it. Thank you! You could do something in your bootstrap file: define( 'ROOT_PATH

Git: How to manage a website with Git? How to use Git for a website -deployment?

半腔热情 提交于 2019-12-06 12:29:49
问题 Originally, I thought my problem was How to maintain branches in Apache's DocumentRoots? but realized the right question actually is How to use Git to deploy stuff to web -server such as Apache? . I feel I have understood now the DocumentRoot -problem, it would require Apache hacking that I want to avoid because much simpler solution using side-effects and putting the repo outside the deployment -dir but now a problem to understand git-fetch-hook and how to deploy stuff if the outside thing

PHP: How to get the document root from inside a user directory?

拥有回忆 提交于 2019-12-06 12:29:18
问题 I develop and deploy various PHP applications to different environments. Especially on development environments, they can be anywhere, from document_root to /Users/me/Sites/ or even /Users/me/Sites/someapp/ Inside these applications I need to know where the 'application root' is, once as the real path and once as URL. Path is no problem. Let's say I have a bootstrap.php in the app root directory which does: define("BASE_DIR", realpath(dirname(__FILE__))); However, I have problems to reliably

Modify document root for nginx proxy under plesk

瘦欲@ 提交于 2019-12-05 20:02:44
I use Plesk with nginx as proxy, which is working good. I installed laravel php framework on a subdomain. the framework provides a direcotry "public" for public files, so I changed document_root with a custom vhost.conf file this way: DocumentRoot "/var/www/vhosts/example.com/laravel.example.com/public" Now apache is aware of this, PHP files working without any problems, but not the static files which are handeled via nginx, I get 404 not found because I must also reconfig the document_root for nginx. If I copy the static files, like css or js on the same dir-level as public it works, but the