Hi
I was chatting with my friend who is into Java/J2EE and I learnt that WAR files is the only way of deployment of a Java web-app. Theres no way to FTP-upload an individual JSP page and run it like the way we can in PHP. I thought this is was a little weird as, for every minor correction, we go to remake the entire WAR file and upload it.
But it seems that php has now brought in that option too (since 5.2.0) by using phar ?
If code can be encrypted or something it would make sense. WAR files have class files, if phar is going to have php source files, then what the use if this ?
Thanks
phar vs WAR
Moderator: General Moderators
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
I'm glad you pointed to that page since I wasn't aware of it and have been looking for something like this 
It just makes it easier to provide bundles of classes (like a library) in a single file which the developer can manage a lot easier than loads of smaller files.
As for the WAR/JAR stuff for Java, that's not true. You can simply provide manifest information from /WEB-INF/web.xml. It's more fiddly making changes to a Java application over the web since the source first needs to be compiled into JVM code though.
It just makes it easier to provide bundles of classes (like a library) in a single file which the developer can manage a lot easier than loads of smaller files.
As for the WAR/JAR stuff for Java, that's not true. You can simply provide manifest information from /WEB-INF/web.xml. It's more fiddly making changes to a Java application over the web since the source first needs to be compiled into JVM code though.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
I thought about it but it looked a little pointless when I came to think about it. The big help with JAR/WAR files is that they contains all environment information. PHP doesn't really need this sort of configuration to run correctly. The phar:// stream looks a bit silly too since you still need to know where things are in the archive and then delcare subsequent includes. If it registered class locations for autoloading or something it would be more worthwhile. Something like:
Code: Select all
phar_import("file:///foo/bar/swift.phar");
$swift = new Swift(new Swift_Connection_SMTP(...));
//No need for further includes- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
In PHP >=5.1 you could simply have the phar file load in a spl_autoload_register() call to do what I wanted. I'll look into it again and see how quick of a job it will be to bundle up phar files as part of my packaging routine.anjanesh wrote:True, but I guess more people (esp startup business oriented who have little tech knowledge) will begin to use since it would be easier for them.
The only way it can be done is using some load.php which'll have all the required require_once statements.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia