Codeigniter: Call to a member function item() on a non-object - codeigniter-2

I have installed Codeigniter 2.1.0 locally, it works great.
But when I upload it to my provider I first get:
Your system folder path does not appear to be set correctly. Please open the following file and correct this: index.php
I can fix this by changing index.php:
$system_path = "system";
$application_folder = "application";
to (why? I never had to do this...)
$system_path = dirname(__FILE__) . "/system";
$application_folder = dirname(__FILE__) . "/application";
But then I get:
Fatal error: Call to a member function item() on a non-object in <path>/Utf8.php on line 47
I can comment out the line but I then get similar error somewhere else.
Please, is this problem at my provider? Or am I doing something wrong? I used CI before and it worked elsewhere flawlessly.
PS: Please not this is completely fresh install of CI.

Yes and no,
the problem is that your provider has probably different web server settings than you do. If he does, you have to adapt the settings, that fits the needs.
The main root cause of this problem is the variety of styles that can express path in the file system. *NIX systems uses forward-slash for expressing folder structure. On Windows machines its a back-slash.
The *NIX systems have root of the file system "/", Windows machines has C:/, D:/ etc...
Every file system has different settings of access rights and their management.
On most of the UNIX systems works locating of the path without a trouble. So if codeigniter tries to determine absolute path of the directory where is CI located, from the "so called" relative directory, he will succeed. If not, it can't work because he don't know where are the files it wants to load.
There are also many bugs across the PHP versions. Eg. there is reported bug with PHP 5.2.0 and Windows Apache that (with certain rights on the directory) the is_dir() function returns False even if the directory is present and it should (and on the other system will) return True.
The most certain way to ensure the path is loaded correctly is to give the CI absolute path. The absolute path varies on OS and eg. on UNIX is /var/www/domain.com/system, on Windows "who knows?". But there is a way how to determine it easily.
Create index.php file in the root folder you can access with this content inside:
<?php phpinfo(); ?>
If you load the page there will be (among other things) stated the absolute path in row with:
_SERVER["DOCUMENT_ROOT"] | /var/www/mydomain.com/
Now if you will assign the absolute path to the $system_path variable it should be sufficient. For greater certainty also assign $application_folder variable.
Note that the path to system folder has to be to the system folder of code igniter and path to application folder has to be to the application folder. So for example:
$system_path = "/var/www/mydomain.com/system";
$application_folder = "/var/www/mydomain.com/application";
After that your site should work flawlessly.
(there are some mentions about this on user guide: http://ellislab.com/codeigniter/user-guide/installation/index.html)

Related

Apache treatment of symbolic links under Windows

Does +FollowSymLinks work with Windows shortcuts? It seems it is completely ignored by Apache under Windows 10.
The importance of this is that, some web frameworks, like Laravel, use this directive to access storage folder (or any other folder outside the public directory) throughout symbolic links. Then, these features are simply ignored in Apache under Windows.
Could anyone, more experienced than I, conform or explain me that? Could you also tell me if there is any workaround?
Thanks for any help!
Shortcuts aren't symbolic links, that's not the same. In order to put a filesystem reference to a file or directory on Windows, you need to use mklink command in either CMD or PS console.
As for Laravel, it ships with no outside dependencies, meaning everything Laravel needs to work aside from PHP itself should be located in the served directory, minding the path in configs. As far as I know, Laravel doesn't use any kind of symbolic links as it is platform-independent, meaning that as long as you have PHP properly configured and compiled with needed extensions, it will work anywhere. It even ships with a default .htaccess used for routing inside /public directory, at least in Laravel 8.
The way Laravel files reference each other is rather simple, check relative paths. Mind they are also implemented as a part of filesystem in any Windows or *nix systems and behave similarly if not identically.
I propose to store the project as is in the config-defined directory and work on your code from there.

ColdFusion 10 directoryCreate and spreadsheetWrite functions including full directory path with forward slashes as part of single folder name on a mac

I am using ColdFusion 10 on a Windows machine. I am creating a directory for storing generated excel reports using directoryCreate() and spreadsheetWrite() cfscript functions. It works fine on Windows.
I have a work colleague who is developing on a mac with OS X mavericks. When the code is executed on his machine, one of two things happens. Either the file includes the full path name in the actual file name (e.g. "/folder/anotherfolder/thefile.xls" as single file name) and is placed in the root of the web project folder, or a single folder is created with the forward slashes as part of the folder name (e.g. "/folder/anotherfolder/" as single folder name).
Here are a couple of examples that I have tried for creating the initial root folder structure:
request.rootPath = ExpandPath("*.*");
request.rootDirectory = GetDirectoryFromPath(request.rootPath);
OR
request.rootPath = ExpandPath("./");
request.rootDirectory = GetDirectoryFromPath(request.rootPath);
OR
request.rootPath = ExpandPath("/");
request.rootDirectory = GetDirectoryFromPath(request.rootPath);
I then use request.rootDirectory in the directoryCreate() function, e.g.:
// within my fw/1 cfc...
rc.userReportPath = "#request.rootDirectory#folder\anotherfolder\";
if (!directoryExists(rc.userReportPath)) {
directoryCreate(rc.userReportPath);
}
And then create the spreadsheet file (where rc.excelFileName is my dynamic file name based on the logged in user:
spreadsheetWrite(rc.s, "#rc.userReportPath##rc.excelFileName#", true);
The only possible clue I've found so far is something to do with forward slashes being unicode characters that are only being displayed as forward slashes, not actual forward slashes for folder path creation (I hope that makes sense). Although, it may have nothing to do with this. The production environment is on a Windows environment so this isn't a major issue going forward, but being a bit obsessive, I'd really like to know what's really causing this behaviour so that I can avoid it in future.
Thanks in advance to anyone that can help me figure this one out :)
(From comments ...)
What is the actual value of the path ie #rc.userReportPath##rc.excelFileName#? Is it actually valid for OSX? It looks like windows style separators are being used ie \.
Try using / instead, which is valid for both windows and mac.

Umbraco Imagegen.ashx and keeping images in another folder

I have an umbraco installation that uses imagegen.ashx.
I would like to deploy it using octopus deploy, this is pretty simpel and is already working.
My problem is that octopus deploys to a new folder (with a version number) each time, which imposes a problem with the media folder, since it can be changed in every folder.
I have made a shared folder at the same level as the versions, and I have made a virtual directory in IIS.
If I access the files directly through a browser - they exist and everything is fine.
But if I use imagegen.ashx it does not work, I have tried setting the imagebasedir property like so:
<Class Name="default" OverridesQueryString="true">
<AllowUpsizing>false</AllowUpsizing>
<MaxHeight>800</MaxHeight>
<MaxWidth>800</MaxWidth>
<ImageBaseDir>D:\Octopus\Applications\customer Test\customer\Shared\ </ImageBaseDir>
</Class>
What am i doing wrong?
ImageBaseDir is unlikely to expect a server mapped path.
The imagegen documentation shows examples that are either relative to the site, or from a fully-qualified url from another site.
Mapping to a path outside of your webroot will likely cause permissions issues for a number of reasons i wont get into here...though i see that you have set up the Media folder as a virtual directory. Good start, however it appears that you're mapping to the d:\ drive instead of the virtual directory you set-up (Presumably this is /Media ?).
You may also look into how the imagegen "Cached" folders are respected by your Octopus set-up. If the imagegen generated images/files get munged, that's a no-good-situation that could leave you with the appearance of missing images:
/(media-virtual-directory)/99999/Cached/index.xml could state that the generated image is # "df1rt0lr.png" -but if that got removed in the deploy process you'll see the missing image behaviour.
Have you used the AltImage property to specify a fallback to a known, always available image? This will help tell if imagegen is throwing errors before outputting your expected result.
I don't believe it's an imagegen issue however, it's a pretty mature product and it's well put together as well being well documented. I would look at using a relative path for ImageBaseDir - or better yet, not using this attribute at all but rather just having your /Media folder being in a constant location as your virtual directory.

codeigniter installation - location of the system and application folders

fellow codeigniters, I’m moving my local ci site onto a media temple server and I’m having a problem with the location of the system and application folders.
the structure of the server is as follows:
../domains
/mysite.com
/html
html is the root of my domain. i.e this is where i’d go when i access www.mysite.com
I placed the ci system folder (ci_system) under domains.
since the html folder is being used by a few ‘under construction’ files, I created a subfolder called ‘mysiteapp’ under html and placed my application folder, idex.php, css, js folders there.
so it looks like this:
../domains
ci_system
/mysite.com
/html
/mysiteapp
/application
/css
/assets
/js
index.php
I edited the index.php file so that $system_folder = “../../../ci_system”;
the problem is, when I access the site, i get a php error:
Warning: require(../../../ci_system/application/config/constants.php) [function.require]: failed to open stream: No such file or directory in /nfs/c08/h04/mnt/xxxxxx/domains/ci_system/codeigniter/CodeIgniter.php on line 52
so it looks like the ci_system folder is being located however CI is still trying to locate the application folder off of the ci_system folder.
I have tried specifying the full path the the application folder but it still tries to concatenate the 2 together.
I have not done many ci installations and my local one was done months ago and i don’t remember it being a pain. so I’m not sure where to look to fix this problem.
hope someone can help.
thanks
Ok So the index.php file does have the $application_folder var which can be set and pointed towards the application dir. Could you be kind enough to share the index.php file? You may have to set both up .. i.e the system folder path and the application folder path.
And the only problem I noticed with your system path is that its relative when the CI doc states that you have to use full server paths...
It is possible to move your application folder to a different location
on your server than your system folder. To do so open your main
index.php and set a full server path in the $application_folder
variable.
$application_folder = "/Path/to/your/application";
If you do want a quick fix, and have shell access, create a sym link, that should fix it quickly, but its just cutting around the corner.
What is inside your ci_system directory? Do you see directories like core, database, libraries etc.?
According to your warning message, you have codeigniter in /domains/ci_system/codeigniter, or you have wrong settings in your index.php.

Move the whole joomla site to a different directoy/subdomain

I am currently developing a joomla 1.5 based site in a temp subdomain (which points to a subfolder on ther sever where all joomla stuff is installed). Currently I am using plugins joomgallery an kunene 1.0.9 (legacy mode).
Once the development is done I would like to move the whole site into the root directory and delete the whole subdomain. How would this ideally be done? Can I just move the files or is there more to it? Any common pitfalls to watch out for? E.g. Are there absolute paths referenced somehwere?
In your configuration.php file, the base path might be defined, something like this:
var $live_site = 'http://temp.mysite.com/';
...though I think by default now, it automatically detects this value for you.
Check in the configuration of your custom components to see if they have got the paths "hardcoded" in there too.
Another thing you could do is set up a .htaccess file with some RewriteRules so that any call to http://temp.mysite.com gets redirected to http://www.mysite.com
There is a free Joomla! extension for this called Joomlapack. Just make a backup with Joomlapack, move the backup files that was created to the new site/folder and run the script that also was created in the backup. Done!
Joomlapack makes a complete backup on both the DB and site files so you can move your site anywhere if you wanted. Joomlapack can be found here: http://www.joomlapack.net/
Make sure to edit your configuration.php file as per these instructions.

Resources