CodeIgniter Forums

Full Version: Changing extension from .php
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Im fairly sure that in one of the older versions of CI, you could change a setting and rename all the files from .php to whatever you wanted, and that made it pretty easy to just rename the file extensions to whatever you want. I dont think you can do that now though.

I know that its terrible practice to edit CI core/system files, but I cant find any other way to do it, any ideas?
There used to be a variable defined in the index.php of CI that stored the extention to be used.

In CI 2.x it was already deprecated:
Code:
// The PHP file extension
// this global constant is deprecated.
define('EXT', '.php');

And it has been removed completely in 3.0. I've checked a few core files and they all have hardcoded '.php' references. Not quite shure why CI made the switch from dynamic to a static situation.

But I neither can imagine why one would want or need to change the file extention of a .php file. The only reason I can think of is using file extentions to force using another php version handler, like using php 6 for .php6 files, php5 for .php5 files etc.
If needed you could change the php handlers for a specific directory/vhost in the apache config itself. This way you can use whatever handler you want without changing any files.
(08-03-2015, 03:36 AM)Diederik Wrote: [ -> ]And it has been removed completely in 3.0. I've checked a few core files and they all have hardcoded '.php' references. Not quite shure why CI made the switch from dynamic to a static situation.

Because changing the filename extension to something else than .php is even more terrible than manually modifying the framework.
(08-03-2015, 03:36 AM)Diederik Wrote: [ -> ]There used to be a variable defined in the index.php of CI that stored the extention to be used.

In CI 2.x it was already deprecated:

Code:
// The PHP file extension
// this global constant is deprecated.
define('EXT', '.php');

And it has been removed completely in 3.0. I've checked a few core files and they all have hardcoded '.php' references. Not quite shure why CI made the switch from dynamic to a static situation.

But I neither can imagine why one would want or need to change the file extention of a .php file. The only reason I can think of is using file extentions to force using another php version handler, like using php 6 for .php6 files, php5 for .php5 files etc.
If needed you could change the php handlers for a specific directory/vhost in the apache config itself. This way you can use whatever handler you want without changing any files.
Yeah, I noticed that, was wondering if there was a way to accomplish it.
And its a constant, not a variable ;-)

(08-03-2015, 04:21 AM)Narf Wrote: [ -> ]
(08-03-2015, 03:36 AM)Diederik Wrote: [ -> ]And it has been removed completely in 3.0. I've checked a few core files and they all have hardcoded '.php' references. Not quite shure why CI made the switch from dynamic to a static situation.

Because changing the filename extension to something else than .php is even more terrible than manually modifying the framework.

Why is it more terrible?
This is from the documentation:

The EXT constant
Usage of the EXT constant has been deprecated since dropping support for PHP 4. There’s no longer a need to maintain different filename extensions and in this new CodeIgniter version, the EXT constant has been removed. Use just ‘.php’ instead.
(08-03-2015, 01:40 PM)jLinux Wrote: [ -> ]
(08-03-2015, 04:21 AM)Narf Wrote: [ -> ]
(08-03-2015, 03:36 AM)Diederik Wrote: [ -> ]And it has been removed completely in 3.0. I've checked a few core files and they all have hardcoded '.php' references. Not quite shure why CI made the switch from dynamic to a static situation.

Because changing the filename extension to something else than .php is even more terrible than manually modifying the framework.

Why is it more terrible?

Because nowadays everything assumes that PHP scripts would have the .php filename extension, including numerous security measures both in PHP itself and outside of it. Therefore, simply changing from .php to something else decreases security and is a disaster waiting to happen.

Worst of all, you have no necessity to do that in the first place; it's a change for the sake of change and that's always bad.
It can be done using .htaccess file, but like Narf said this is very bad practice.

Remove file extension.
(08-04-2015, 03:57 AM)InsiteFX Wrote: [ -> ]It can be done using .htaccess file, but like Narf said this is very bad practice.

Remove file extension.

That's completely unrelated to this question, and not really very relevant to any PHP framework which routes all requests through a single file (like CI does with index.php), unless you want to use index in your URL instead of index.php (or removing it completely).