CodeIgniter Forums
Changing extension from .php - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Changing extension from .php (/showthread.php?tid=62590)



Changing extension from .php - jLinux - 08-02-2015

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?


RE: Changing extension from .php - Diederik - 08-03-2015

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.


RE: Changing extension from .php - Narf - 08-03-2015

(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.


RE: Changing extension from .php - jLinux - 08-03-2015

(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?


RE: Changing extension from .php - msteudel - 08-03-2015

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.


RE: Changing extension from .php - Narf - 08-04-2015

(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.


RE: Changing extension from .php - InsiteFX - 08-04-2015

It can be done using .htaccess file, but like Narf said this is very bad practice.

Remove file extension.


RE: Changing extension from .php - mwhitney - 08-04-2015

(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).