When I run phpinfo() and look by the Configuration category under PHP Core, I see a directive titled include_path, with a local value and a master value.
In this case, my local value is set to
.:
./include:
../include:
/usr/share/php:
/usr/share/php/smarty:
/usr/share/pear
and my master value is set to
.:
/usr/share/php:
/usr/share/pear:
/usr/share/php/pear:
/usr/share/php/smarty
The reason I am trying to learn how this works is because there is a file in the system I am working on titled Smarty.class.php, which I'm sure sounds very familiar to anyone who uses Smarty Templating Engine.
One of the PHP files has the following includes:
require_once("Smarty.class.php");
require_once("user_info_class.inc");
The file user_info_class.inc is in the same directory as the file making the include, which makes perfect sense to me, and is the way that I've always referenced files. I decided that I wanted to open up the Smarty.class.php file and had assumed it would be in the same directory, but it was not.
After doing a bit of digging, I discovered those php_ini variables, and was finally able to locate the file in the directory usr/share/php/smarty/.
So it would seem that when making an include, it follows some sort of order between the Local and Master values for the include_path.
Assuming that my deductions were correct thus far, can someone explain the order in which PHP searches for the files to be included?
The global value is basically what's set in php.ini. The local value is what's currently being used. The local value completely overwrites the master value.
According to the manual, PHP checks the paths in the order that they are specified in the include_path setting: http://php.net/manual/en/ini.core.php#ini.include-path
Related
I am trying to implement server.execute() via an include from a virtual functions library (<!-- #include virtual="lib/functions.asp"-->) that I can call on from any subfolder in the system. I am trying to implement a new function that should exist on all pages in our system, and it would be virtually unfeasible to go in and add it manually to every single page. And I need it to be implemented in such a way that it does not interfere with the code on any page which is why I am doing it as a server.execute() in a virtual lib that I know already exists everywhere in the system.
For example:
'location of routine.asp = https://example.com/admin/routine/routine.asp
Server.Execute("routine/routine.asp")
'Will work if I add the virtual lib from an ASP-page in the admin subfolder, but not if I call it from another subfolder
Server.Execute("https://example.com/admin/routine/routine.asp")
'Does not work, because server.execute can't handle that kind of fixed path
The documentation clearly states that colons and double-slashes are not allowed, but I can't figure out how I can make sure the execution of the file happens no matter where in the system it's called from.
Question: How can I make server.execute(path)'s path handle a fixed path, or change the path dynamically to make sure I can always target the file correctly?
If you want to use an absolute path make sure you are using an absolute path (full path from the root).
Think you simply need to specify the absolute path explicitly;
Server.Execute("/admin/routine/routine.asp")
I am creating an extract from sequential file. I created a parameter with the correct file location and when I try to "View Data", it says it can't find the file. If I hard code the location it finds the file and I am able to "View Data".
example:
#filedirectory# = aaa/bbb/ccc/
so my entry for "File" is #filedirectory#filename.txt and this does not work
however, the following does work
aaa/bbb/ccc/filename.txt
Any ideas what would cause this?
Try using the absolute path. Start with a / and the root directory.
Second point is that the parameter itself does not have "#". The "#" are only needed to reference it - in the Sequential File stage. So name it filedirectory when you define it in the job.
Recommendation:
As filedirectory will probably be used throughout your project I recommand using a ParameteSet.
I had the same issue, and it happened I forgot to include the directory parameter before the file parameter. Hope this information helps someone.
I need to reference patients.json from patients.go, here's the folder structure:
If I do:
filepath.Abs("../../conf/patients.json")
it works for go test ./... but fails for revel run
If I do:
filepath.Abs("conf/patients.json")
the exact opposite happens (revel is fine but tests fail).
Is there a way to correctly reference the file so that it works both for tests and normal program run?
Relative paths are always interpreted / resolved to a base path: the current or working directory - therefore it will always have its limitations.
If you can live with always taking care of the proper working directory, you may keep using relative paths.
What I would suggest is to not rely on the working directory, but an explicitly specified base path. This may have a default value hard-coded in your application (which may be the working directory as well), and you should provide several ways to override its value.
Recommended ways to override the base path to which your "relative" paths are resolved against:
Command line flag (see flag package)
Environment variable (see os.Getenv())
(Fix named) Config file in user's home directory (see os/user/User and os/user/Current())
Once you have the base path, you can get the full path by joining the base path and the relative path. You may use path.Join() or filepath.Join(), e.g.:
// Get base path, from any or from the combination of the above mentioned solutions
base := "/var/myapp"
// Relative path, resource to read/write from:
relf := "conf/patients.json"
// Full path that identifies the resource:
full := filepath.Join(base, relf) // full will be "/var/myapp/conf/patients.json"
I've never used Revel myself but the following looks helpful to me:
http://revel.github.io/docs/godoc/revel.html
revel.BasePath
revel.AppPath
This is not the problem with path, but the problem with your design.
You should design your code more careful.
As far as I can tell, you share same path in your test file and reveal run. I guess that maybe you hard code your json path in your model package which is not suggested.
Better way is
model package get json path from global config, or init model with json path like model := NewModel(config_path). so reveal run can init model with any json you want.
hard code "../../conf/patients.json" in your xxxx_testing.go
I am writing a small tool in c++. It is actually more of a framework that is open to customization. It has the following directory structure (simplified example).
src/
main/myexec # linked to libapple.so
apple/
coder/libapple.so
john/libapple.so
.
.
james/libapple.so
Here, the directory "coder" is a generic dummy, with some example code to generate libapple.so. Different users can checkout this tool, create directories of their own, copy the template code from "coder" and customize as they wish. Depending on the configure option (indicating the user), the respective libapple.so needs to be generated.
As I mentioned, this is a simplified example. It is not a matter of generic programming, inheritance etc. In fact, similar to the "apple" folder there are others like "scripts", "docs", "configs" etc each having similar user specific folders. Also, the tool will be maintained at a single repository location to allow me to support & maintain all the code that is not specific to user. As a policy, users are expected to modify and check-in only the contents of their folders.
The problem I am facing is with "configure.ac". I do not want to use "AC_ARG_WITH" option as it would require each new user to edit configure.ac. Also for each user the AC_CONFIG_FILE entries would be exactly the same except for his folder name. I tried using "--enable-user=User" and then AC_SUBST(USERDIR), which also helps in setting "SUBDIRS = #USERDIR#" in Makefile.am. Everything looks good except for the fact that "Makefile.in" is not getting created under the user folder when I specify "AC_CONFIG_FILE = ([apple/${USERDIR}/Makefile])".
Please advice how to overcome this issue. In the worst case I may end up in creating softlinks :(
After one full day of scratching my head, following is the solution that I have come up with.
Create a file "project_makefiles.m4.in" like this
AC_CONFIG_FILES([ apple/USERDIR/Makefile ]
Add the below to configure.ac
m4_include([project_makefiles.m4])
Create a wrapper script like "build.sh" which will create "project_makefiles.m4" from "project_makefiles.m4.in" by replacing "USERDIR". This is done before the automake.
Can someone offer some advice on how to get started with mathematica packages?
I can save the following in a file named "Foo.m". When I run the input cell in that file, I can see the effects reflected in $ContextPath variable.
BeginPackage["Foo`"]
bar::usage = "barfunction";
Begin["`private`"]
bar[w_] := w;
End[];
EndPackage[];
However, in my notebook I have the following:
#include<foo>
SetDirectory[ToFileName[{$HomeDirectory, "My Documents", "mathematica"}]];
Needs["Foo`"]
$ContextPath
But the needs call is failing for some reason, and the $ContextPath remains unchanged.
Edit
I believe that I've got a partial solution working now, the cell in my file wasn't marked as an initialization cell - and whilst I can now <<Foo', Needs["Foo"]` still isn't working correctly.
Check to make sure the saved file, "Foo.m", is on your $Path, which tells Mathematica which directories to look in when trying to load packages, much like the PATH environment variable in Unix or Windows.
EDIT: $ContextPath won't be changed unless there's an actual BeginPackage statement (or you manipulate it directly using Set or Block or something).
EDIT the second: One thing to check is what
FileNames["Foo.m", $Path]
returns. What you're describing does sound a little strange, though.
Either form should work. When a file is loaded using Get (or <<) or Needs, the directory on the top of the DirectoryStack[] is searched first, and then the $Path is searched. (SetDirectory does not change $Path, so FileNames["Foo.m", $Path]won't find Foo.m.) However, FindFile by default searches Directory[] and $Path. You can test it by doing the following:
FindFile["Foo`"]
SetDirectory[<Foo dir>]
FindFile["Foo`"]
it should return
$Failed
<Foo dir>
<Foo dir>/foo.m
If FindFile can find Foo.m then Needs should be able to find it. In general, I put my packages in $UserBaseDirectory/Applications, and Needs picks them up just fine.