Porting a website from ASP.Net to PHP - Bad Idea?



  • Guys, I have a question.

    I am working on an ASP.Net website, the development of which is plodding along at an unacceptably slow pace because of my lack of ASP.Net expertise (though I am well-versed in ASP - which might be irrelevant), and the fact that everything needs to be done enterprise-ily in .Net.

    The website is still in very early development (only the database, and some data-entry forms have been created).

    I am thinking of porting the application to PHP, using the CodeIgniter framework. The reason being that I have gained significant experience on PHP in the past few months.

    I feel confident that coding in PHP will accelerate development by an order of magnitude, and as long as I follow best-practices (the PHP framework is helping by allowing me to use MVC, reusing libraries, etc.). My goal is to develop a decent, maintainable, robust website.

    As I was examining the existing SQL Server database, and wondering how I could port it into MySQL, I realized something scary - most of the stuff I'd taken for granted in MSSQL, like relationships, stored procs, etc., have little or no support in MySQL.

    And now, the question:

    Is PHP/MySQL a feasible, logical solution for what I have in mind? Will MySQL destroy any chances I have of writing a decent, robust website? Or if I make sure to follow best-practices while designing the database, will it be just as good as a database in MSSQL? Any other suggestions?



  • a) Going from a sane language to PHP is odd

    b) If you want to do it anyway, but need SQL-Server features, why not use PHP with SQL-Server?

     

    If the answer for b) is "because the PHP-API for MS-SQLServer is different to the API for MySQL", goto a)



  • I've just completed a migration of a .Net/MsSql site to PHP/MySql and can I just say thank god it's over!

    The MsSql -> MySql was easy enough as my database wasn't that large and of low complexity. I also didn't have a lot of stored procedures, so it wasn't so tricky. I had an operating database within a day. The issue I'm still addressingis how to detect a failure when updating a MyISAM and InnoDB table in the same tx for a full text index. (MyISAM isn't transactional, InnoDB can't have FTI's).

    The .Net to PHP was the killer. I had to change, more or less, every line. I also had to architect some sizable changes due to the differences in IIS and Apache.

    • No application state or web cache. I was caching some menu data used throughout the site in web cacahe, then tuff luck. I'm using Pear and it's doing ok.
    • The regular expression implementation was a little tricky to cut over. Not the reg ex's themselves, but the php implementation.
    • XML queries in PHP are all xpath queries. Forget "selectSingleNode".
    • Use the "Imporved" MySql interface. Forget the basic one, especially if you're calling stored procedures.
    • Use the Eclipse dev tool, spend the time and get it working. It's worth it.

    In short, this is the best decision I've made. I've been microsofting around for nearly 10 years now and I'm glad I've cut it over. So many more affordable options come onto my plate. My plan (forgive my optimism!) is for my sites to be huge successes, and when they are, I don't want to be faced with massive bills for licenses, licenses and more licenses. Overnight success isn't uncommon in the IT industry and I have no plans on missing that boat because I couln't afford a MsSql cluster.

    Good luck!

     



  • @ammoQ said:

    a) Going from a sane language to PHP is odd

    ammoQ, could you expand on that a bit? I know some of the advantages of .Net, like increased execution speed, security, and platform independence. Increased development time, reduced code, etc. are non-realized goals for me, possibly because of the lack of my experience. I have found that it takes me much longer, and is much more difficult to make changes to existing code during development.

    However, it worries me that my application might be any less reliable if I coded in PHP - in spite of using a framework with the MVC design pattern, using PHP5, and following the best practices as far as I can - am I missing something? 

    @Pivot said:

    I've just completed a migration of a .Net/MsSql site to PHP/MySql and can I just say thank god it's over!



    Thanks for your reply - your experience seems quite relevant. The MSSQL -> MySQL is my primary concern - I have no worries about converting my ASP.Net code to PHP, since most of it is auto-generated (tableadapters, data controls, etc.). The custom code I've written is almost entirely for the data access layer. If I can accomplish the same in PHP in a few days, I think it will more than make up for writing from scratch. I think manually creating the database might be an option, since there's only test data in my dev. database, and the amount of tables is around 10-15, so it should be a day or twos worth of work. Do you know of any other good options to export the database structure to MySQL? Something free and simple.

    Regarding the changes to the system design and architecture, most of the hard-lifting is being done by my framework (CodeIgniter). I am depending upon it to abstract away most of the tricky stuff, like the data access layer, session management, validation, etc. I am using Zend Studio (based on Eclipse) for development, which is proving to be exceptionally useful for PHP development.

    Are there any other roadblocks you can foresee? 



  • @donniel said:

    ammoQ, could you expand on that a bit? I know some of the advantages of .Net, like increased execution speed, security, and platform independence. Increased development time, reduced code, etc. are non-realized goals for me, possibly because of the lack of my experience. I have found that it takes me much longer, and is much more difficult to make changes to existing code during development.
     

    Why wouldn't you just learn ASP.NET?

    It is so much easier to learn a language/technology than it is to rewrite a sizable app.



  • @MasterPlanSoftware said:

    @donniel said:

    ammoQ, could you expand on that a bit? I know some of the advantages of .Net, like increased execution speed, security, and platform independence. Increased development time, reduced code, etc. are non-realized goals for me, possibly because of the lack of my experience. I have found that it takes me much longer, and is much more difficult to make changes to existing code during development.
     

    Why wouldn't you just learn ASP.NET?

    It is so much easier to learn a language/technology than it is to rewrite a sizable app.



    To be honest, there isn't that much to rewrite - though I've spent a large amount of time on the website, a lot of the time was spent in designing the database structure, the appropriate stored procedures, etc, which I'm hoping is largely transferable. The code I've created just covers a large part of the administration console and deals with data input. With the prior knowledge of each module that I have, I think it will be much easier for me to write the same code in PHP. I'm afraid that if I 'learn as I go' in ASP.Net, I'll write worse code than if I apply my knowledge, alongwith good coding practices in PHP. For example, what use are the advanced exception handling and logging frameworks of ASP.Net, if I don't know them beyond a simple Try-Catch? I may be wrong about this.

    I'm willing to spend the time and effort of learning ASP.Net, but I'm still looking for a good reason why I should. I'm looking for either structural defects in PHP/MySQL (please assume I'm using sane code, and thanks to the CodeIgniter framework, am achieving MVC concern separation), or structural advantages in ASP.Net that can be weighed in relation to the time and effort required for me to learn ASP.Net.



  • @donniel said:

    The custom code I've written is almost entirely for the data access layer. If I can accomplish the same in PHP in a few days, I think it will more than make up for writing from scratch. 

    I wrote my DAL from scratch as well. Not only did it help me brush up on my PHP, but helped me gain a good understanding of the mysqli interface. You need it!

    @donniel said:

    I think manually creating the database might be an option, since there's only test data in my dev. database, and the amount of tables is around 10-15, so it should be a day or twos worth of work. Do you know of any other good options to export the database structure to MySQL? Something free and simple.

    I used this ... http://www.kofler.cc/mysql/mssql2mysql.txt

    Free and simple!

    @donniel said:

    Regarding the changes to the system design and architecture, most of the hard-lifting is being done by my framework (CodeIgniter). I am depending upon it to abstract away most of the tricky stuff, like the data access layer, session management, validation, etc. I am using Zend Studio (based on Eclipse) for development, which is proving to be exceptionally useful for PHP development.

    Are there any other roadblocks you can foresee? 

     

    The main issue I'm dealing with is the change in environment itself. Keyboard shortcuts in eclipse are different, apache is different (to iis), file system is different, and permissions are different. Being patient with yourself whilst you change gears helps.<o:p></o:p>

     

     




  • @donniel said:

    To be honest, there isn't that much to rewrite - though I've spent a large amount of time on the website, a lot of the time was spent in designing the database structure, the appropriate stored procedures, etc, which I'm hoping is largely transferable. The code I've created just covers a large part of the administration console and deals with data input. With the prior knowledge of each module that I have, I think it will be much easier for me to write the same code in PHP. I'm afraid that if I 'learn as I go' in ASP.Net, I'll write worse code than if I apply my knowledge, alongwith good coding practices in PHP. For example, what use are the advanced exception handling and logging frameworks of ASP.Net, if I don't know them beyond a simple Try-Catch? I may be wrong about this.

    I'm willing to spend the time and effort of learning ASP.Net, but I'm still looking for a good reason why I should. I'm looking for either structural defects in PHP/MySQL (please assume I'm using sane code, and thanks to the CodeIgniter framework, am achieving MVC concern separation), or structural advantages in ASP.Net that can be weighed in relation to the time and effort required for me to learn ASP.Net.

     

    So you are just trying to start a language/platform flamewar?

    Use whatever you are good at and comfortable with. Don't creep around forums asking everyone if PHP is better than ASP.NET.

    They are two different platforms that are very different and each one provides advantages and disadvantages.

    But if you have PHP experience, and you dont plan to learn ASP.NET where is the decision?

     

    I could be wrong, but I think you are only trying to stir up a platform flamewar here. Hopefully no one will take your bait.



  • @donniel said:

    However, it worries me that my application might be any less reliable if I coded in PHP - in spite of using a framework with the MVC design pattern, using PHP5, and following the best practices as far as I can - am I missing something?

    Why would the choice of language make it less reliable?  You should probably stay away from CodeIgniter, though.  It's written for PHP4.  My recommendation is to just roll your own web MVC framework.  I've used several PHP MVC frameworks in the past and all were shoddy and obnoxious so I've just written my own.  It's not as hard as it sounds, the web MVC parts only comprise about 1000 lines of code.  However, if you really want a bloated, Java-esque nightmare of over-engineered class hierarchies I'd recommend Zend Framework as that is at least meant to run on PHP5 and is written by Zend.

     

    As far as using MySQL, I don't know why you think it lacks relations and stored procedures.  MySQL 5 has had these for some time.  Of course you can always use MSSQL if that's what you prefer.  I would recommend staying away from mysqli.  Also, PDO has provided a standard DB layer for PHP for some time if that's your thing, so you can safely disregard ammoQ's misinformed comment about different database APIs.



  • @Pivot said:

    @donniel said:

    The custom code I've written is almost entirely for the data access layer. If I can accomplish the same in PHP in a few days, I think it will more than make up for writing from scratch. 

    I wrote my DAL from scratch as well. Not only did it help me brush up on my PHP, but helped me gain a good understanding of the mysqli interface. You need it!


    Woah! I think I miscommunicated that! When I said I wrote the DAL, I was referring to ASP.Net - and that too, of course, was basic code utilizing data adapters, datasets, etc. I don't intend to create a DAL for my PHP project. In fact, as I stated earlier, I am using a PHP framework (CI) precisely to abstract away database access, etc. 

    @Pivot said:

    @donniel said:

    Regarding the changes to the system design and architecture, most of the hard-lifting is being done by my framework (CodeIgniter). I am depending upon it to abstract away most of the tricky stuff, like the data access layer, session management, validation, etc. I am using Zend Studio (based on Eclipse) for development, which is proving to be exceptionally useful for PHP development.

    Are there any other roadblocks you can foresee? 

    The main issue I'm dealing with is the change in environment itself. Keyboard shortcuts in eclipse are different, apache is different (to iis), file system is different, and permissions are different. Being patient with yourself whilst you change gears helps.

     


    Good advise, and thanks for the link! I'd seen it before, but wasn't 100% sure about it...will explore it further.

    @MasterPlanSoftware said:

    I could be wrong, but I think you are only trying to stir up a platform flamewar here. Hopefully no one will take your bait. 

    Yes, you are wrong. I am not.

    @morbiuswilters said:

    Why would the choice of language make it less reliable?  You should
    probably stay away from CodeIgniter, though.  It's written for PHP4. 
    My recommendation is to just roll your own web MVC framework.  I've
    used several PHP MVC frameworks in the past and all were shoddy and
    obnoxious so I've just written my own.  It's not as hard as it sounds,
    the web MVC parts only comprise about 1000 lines of code.  However, if
    you really want a bloated, Java-esque nightmare of over-engineered
    class hierarchies I'd recommend Zend Framework as that is at least
    meant to run on PHP5 and is written by Zend.

    I've pretty much shortened my options to PHP+CodeIgniter, or ASP.Net - like MPS pointed out, it would be better to learn ASP.Net (since I seem to have such a high opinion of it ;)) than to learn a complicated framework like Zend (yes, I said complicated - I'm not very smart, apparently), or to write my own DAL. If I could write those 1000 lines in the first place, I wouldn't even have worried about this choice. :)

    So this is what I've come away with, from the discussion:

    What's more important is to go with the language I'm comfortable in, just making damn sure that the code I write is of the best quality (and is not wtf-worthy).

    Thanks, guys.



  • @ammoQ said:

    a) Going from a sane language to PHP is odd

    b) If you want to do it anyway, but need SQL-Server features, why not use PHP with SQL-Server?

    If the answer for b) is "because the PHP-API for MS-SQLServer is different to the API for MySQL", goto a)

    I'd definitely switch platforms if I were given something done in .NET ... but I'd switch to Java. MSSQL however is decent enough to do the job, so I'd remain with that DBMS, even if I prefer DB2, Oracle or PostgreSQL if I were to go the OpenSource way. (I don't do MySQL anymore, though most of my reasons to ditch MySQL were fixed in MySQL 5.)

    I think the OP's lucky to have that option of switching platforms; most of the time the technology is already defined by the higher-ups and you're forced to use it, no matter how crappy that is. This is also why I refuse jobs that ask for VB experience.

    However, in switching platforms you should take into account how much will you lose on that ... for example, I wouldn't ditch an already bought SQL server.



  • @donniel said:

    I've pretty much shortened my options to PHP+CodeIgniter, or ASP.Net - like MPS pointed out, it would be better to learn ASP.Net (since I seem to have such a high opinion of it ;)) than to learn a complicated framework like Zend (yes, I said complicated - I'm not very smart, apparently), or to write my own DAL. If I could write those 1000 lines in the first place, I wouldn't even have worried about this choice. :)

    Zend is complicated, absolutely.  I think it's far too complicated for what it is attempting to do, just like a lot of the Java frameworks out there.  My point was that CI didn't look much less complicated to me, but it's your call.

     

    @donniel said:

    So this is what I've come away with, from the discussion:

    What's more important is to go with the language I'm comfortable in, just making damn sure that the code I write is of the best quality (and is not wtf-worthy).

    This is pretty good advice all around.  One of the things I like about PHP is that it's easy and quick to throw up a simple application but the language is also suitable for very large apps.  In this day and age most of the mainstream languages are similar enough that you can't really go wrong with any of them.  What causes far more problems is not knowing good practices for a language.



  • @donniel said:

    @ammoQ said:

    a) Going from a sane language to PHP is odd

    ammoQ, could you expand on that a bit?

     

    I don't want to add yet-another-php-sucks article, so I just point to a prominent and recent one:

    http://www.codinghorror.com/blog/archives/001119.html

    and another one, more elaborate:



  • @ammoQ said:

    http://www.codinghorror.com/blog/archives/001119.html

    Jeff Atwood provides absolutely no evidence of PHP sucking.  I've heard it all before, too, and it's usually misinformed bullshit.

     

    @ammoQ said:

    http://www.bitstorm.org/edwin/en/php/

    1.  PHP does recursion alright.  The bug linked in the article is 9 years old and it seems PHP can definitely handle around 25,000+ recursive calls before exhausting memory.  If your app needs more recursion than that, you're probably better off using something else.

    2. This is hardly true anymore, most of the modules are thread-safe.  They're also frequently 3rd party so it's not a criticism of the language but instead of libraries available for it.  What's more, there's no real reason to run Apache in multi-threaded mode on UNIX so the point is moot.

    3. PHP is not crippled for commerical reasons, it's just that the VM doesn't support opcode caching.  There have been many free options available for opcode caching for years and PHP6 will contain APC by default.  If you need the speed increase, you will use an opcode caching extension.  Otherwise, who cares?

    4. Namespaces have been added to PHP6 but quite frankly I've never seen a need for them.  How often are you loading more than one function with the same name, anyway?  I've never run into a problem.

    5. So it uses different date formatting characters.  BFD.  And bringing Smarty into it is just moronic.  Smarty is a 3rd party library so claiming confusion because they have adopted the standard C formatting characters and then holding that against PHP is disingenuous at best.

    6. I've never seen a big problem with licenses, but the same thing can be said about any language.  Guess what, C also has the ability to use different 3rd party libraries with incompatible licenses!  OMFG!  Somebody call the press!

    7. Agreed.  The naming is frequently obnoxious but that doesn't seem like that big of a complaint to me.  It's messy, sure, but I don't have that hard of a time remembering the built-in functions and their parameters and if I do the php.net documentation is readily available.  What's more, any decent IDE will provide auto-complete and parameter hinting.

    8. Magic quotes is a retarded setting.  It never should have been included in PHP to begin with.  It does not make apps more secure and it has been off by default for some time.  It's also being pulled in the future, IIRC.  It does make writing code for different systems annoying, but it's also trivial to work around if you need to.

    9. PHP probably has more web frameworks available than any other language.  So it's the fault of the language that developers don't leverage them?  Hell, a lot of simple apps don't even need a framework but it's not like finding one is difficult.  Any developer who is familiar with the concept will Google "php framework" and have dozens upon dozens to choose from.

    10. PHP has Unicode extensions.  The built-in string functions are ASCII-only but it's not like Unicode isn't available.  Personally I'm glad both are provided, although it probably would have been a better idea to make Unicode the default and ASCII the extension.  ASCII strings are better if you are dealing with performance-sensitive software that doesn't need Unicode so it should be an option.

    11. Bullshit.  PHP is slow if you don't bother to do any kind of optimization on the web server and if you don't install an opcode cache.  Otherwise it's quite capable of churning out requests at a snappy rate.



  • Otherwise, I'd love to continue with MSSQL! @danixdefcon5 said:

    @ammoQ said:

    a) Going from a sane language to PHP is odd

    b) If you want to do it anyway, but need SQL-Server features, why not use PHP with SQL-Server?

    If the answer for b) is "because the PHP-API for MS-SQLServer is different to the API for MySQL", goto a)


    ...

    However, in switching platforms you should take into account how much will you lose on that ... for example, I wouldn't ditch an already bought SQL server.



    The only worry about using MSSQL with PHP is that I am currently in a shared hosting environment, that only provides MySQL. Will need to figure out what my options in that regard are. I'll obviously ditch the ASP.Net hosting plan I've got, and migrate to the PHP hosting plan I've got - but I might have to consider finding a host that provides PHP + MSSQL, or host MSSQL somewhere where there's support for remote connections.


  • @donniel said:

    ...or host MSSQL somewhere where there's support for remote connections.

    SQL over the Internet?  That's a real WTF there.  You're better off looking for a hosting provider that does PHP + MSSQL.  There are so many PHP providers that there surely has to be one that does MSSQL.  Another option is to just get a Windows VPS and install PHP and MSSQL on it.  That will be a tad more expensive (~$45 a month) but give you more control over the setup. 



  •  @donniel said:

    I know some of the advantages of .Net, like increased execution speed,

    Speed depends largely on the programmer and how the program is wrote, not the language. Choosing a language for speed is like choosing a car for it's tires.Sure it makes some difference, but it doesn't matter, and there are work arounds.

    security,

    I can code a security hole in php, I can code a security hole in ASP .NET I can code a security hole in C, all without knowing it. It depends on the programmer(s), not the lanaguage to fix security holes that they create.


    and platform independence.

    I go home everyday after work and program in all the .NET languages on my linux box all the time! I just have this problem of lacking any type of compiler or IDE. Seems that Ubuntu can't run or compile VB .NET code.



  • @malfist said:

    I go home everyday after work and program in all the .NET languages on my linux box all the time! I just have this problem of lacking any type of compiler or IDE. Seems that Ubuntu can't run or compile VB .NET code.
     

    What are you talking about?

    MonoDevelop and Mono, ever heard of them? Mono is primarily C#, but there is VB support.



  •  Mono is Mono is Mono, an emulation, a port. Not the real thing.



  • @malfist said:

     Mono is Mono is Mono, an emulation, a port. Not the real thing.

     

    WTF are you talking about??

    Mono wasn't written by MS, so it must be junk?

     

    Quick alert Apple and the Linux community!



  •  Did I say it was junk? No. The only thing I said was that it wasn't the real thing. If I program in Mono, it's Mono's language,Mono decides the specifications. M$'s compiler does not.



  • @malfist said:

     Did I say it was junk? No. The only thing I said was that it wasn't the real thing. If I program in Mono, it's Mono's language,Mono decides the specifications. M$'s compiler does not.

    You are a fucking idiot. Through and through.

    C# has a specification. Mono's C# compiler is built to this. Their framework is identical to the .NET framework, but obviously references Linux system calls instead of Windows.

     

    It is not "mono's language". I don't where the hell you got that from, but you should think about educating yourself before making stupid comments here.



  •  Yeah well, HTML has specifications too. It's 'mono's language' in the same way as HTML is 'firefox's language' when HTML is iterpreted by firefox. It has quarks that are specific to Mono, as will HTML has quarks specific to Firefox. TurboPascal follows the same specs as Pascal, yet they're not the same thing. Sorry if I wasn't clear enough for you to understand. Maybe you should take some time and try to understand what I said instead of say 'nope, your wrong, and stupid.'



  • @malfist said:

     Yeah well, HTML has specifications too. It's 'mono's language' in the same way as HTML is 'firefox's language' when HTML is iterpreted by firefox. It has quarks that are specific to Mono, as will HTML has quarks specific to Firefox. TurboPascal follows the same specs as Pascal, yet they're not the same thing. Sorry if I wasn't clear enough for you to understand. Maybe you should take some time and try to understand what I said instead of say 'nope, your wrong, and stupid.'

     

    Well, considering you keep calling Mono a language, it is easy to call you stupid.

    Now, I use Mono and .NET daily and my projects go between platforms with no significant issues.

    Would you care to enlighten me on these issues that you are referring to?



  •  Yet again you mis understand me, I refered to C# under mono as Mono's implementation of the lanaguage, not Mono is a language. You completely and totally missed the point of my previous post.



  • @Pivot said:


    @donniel said:

    I think manually creating the database might be an option, since there's only test data in my dev. database, and the amount of tables is around 10-15, so it should be a day or twos worth of work. Do you know of any other good options to export the database structure to MySQL? Something free and simple.

    I used this ... http://www.kofler.cc/mysql/mssql2mysql.txt

    Free and simple!

     

     BTW, for anybody who happens to stumble on to this thread: MySQL has a fantastic set of GUI tools: http://dev.mysql.com/downloads/gui-tools/5.0.html. This includes a migration toolkit, that according to me, should be one of the best and most reliable ways to export the database schema and data from source databases to MySQL. It's free, comprehensive, and is very easy to use.



  • @malfist said:

    You completely and totally missed the point of my previous post.
     

    I got the point. And the point was stupid.



  • @MasterPlanSoftware said:

    @malfist said:

    You completely and totally missed the point of my previous post.
     

    I got the point. And the point was stupid.

     

     

    Then you sir, are a moron.


Log in to reply