SitePoint Sponsor

User Tag List

Page 1 of 3 123 LastLast
Results 1 to 25 of 73
  1. #1
    SitePoint Zealot
    Join Date
    Mar 2004
    Location
    Netherlands
    Posts
    138
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question PHP alternative for Ruby on Rails?

    Hi, is anyone aware of a (open source) PHP alternative for Ruby on Rails?
    I'm especially interested in a comparable ActiveRecord library.

    For those of you who don't know Ruby on Rails, check out http://www.rubyonrails.com/ . It's a very interesting project.

    I think almost all people doing 'database web applications' (wether they use a standard or homegrown framework, or even none at all) could learn something from it.

    Recently, the Django project (a RoR clone for Python) has been announced. http://www.djangoproject.com/

    PHP should have something like this too, don't you think?

  2. #2
    eschew sesquipedalians silver trophy sweatje's Avatar
    Join Date
    Jun 2003
    Location
    Iowa, USA
    Posts
    3,749
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Take a look at Cake PHP.
    Jason Sweat ZCE - jsweat_php@yahoo.com
    Book: PHP Patterns
    Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
    Detestable (adjective): software that isn't testable.

  3. #3
    SitePoint Enthusiast
    Join Date
    Mar 2004
    Location
    Shorewood, IL
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The site is now here:
    CakePHP
    /**
    * @author Larry E. Masters aka PhpNut
    * @url CakePHP Rapid Development Framework
    */

  4. #4
    Resident Java Hater
    Join Date
    Jul 2004
    Location
    Gerodieville Central, UK
    Posts
    446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As people have pointed out, Cake is the PHP port. Other languages like Java have ports too (Trails), etc, but I doubt you will find the ports half as good as the original rails. The reason being is that Rails exploits a lot of Ruiby-specific language features.

  5. #5
    SitePoint Zealot
    Join Date
    Mar 2004
    Location
    Netherlands
    Posts
    138
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    MiiJaySung, what kind of language features would that be?
    Maybe you know RoR better than me... I don't have hands on experience with it, and also haven't examine the source yet. I just read a lot of tutorials, watched some moviews, and was impressed.

    Do you think the Rails API would be much harder to implement in PHP then it is in ruby?

  6. #6
    SitePoint Zealot
    Join Date
    Mar 2004
    Location
    Netherlands
    Posts
    138
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sweatje, 1phpnut: thanks for the pointers to CakePHP. I'll take a look.

  7. #7
    SitePoint Enthusiast
    Join Date
    Mar 2004
    Location
    Shorewood, IL
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by MiiJaySung
    As people have pointed out, Cake is the PHP port. Other languages like Java have ports too (Trails), etc, but I doubt you will find the ports half as good as the original rails. The reason being is that Rails exploits a lot of Ruiby-specific language features.
    I would not call it a port, the concepts are similar but it is not a port of RoR to PHP.

    Could you give more detail in these "Ruby-specific language features"?

    I see people bring this up often, and still do not see what this has to do with "tools" like these.

    RoR, Trails, Cake, etc where created to make application development faster in the language they are wrote for.
    I like Ruby and RoR do not get me wrong, the OO in it is great.

    But show me something that can be done RoR, that can not be done in PHP?

    I am talking about something that is impossible to do in PHP, not something that is easier to do. If code can be wrote in PHP, Java or what ever language, and methods created to make it easier and faster to develop other applications, that would not count
    /**
    * @author Larry E. Masters aka PhpNut
    * @url CakePHP Rapid Development Framework
    */

  8. #8
    SitePoint Enthusiast
    Join Date
    Mar 2004
    Location
    Shorewood, IL
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by meryn
    MiiJaySung, what kind of language features would that be?
    Maybe you know RoR better than me... I don't have hands on experience with it, and also haven't examine the source yet. I just read a lot of tutorials, watched some moviews, and was impressed.

    Do you think the Rails API would be much harder to implement in PHP then it is in ruby?
    I do not think so, I have been adding many things to Cake that are simliar to the way things are done in RoR.
    The sytax is different of course, but you will see over the next few releases, many things being added.

    I currently have, $hasOne, $hasMany working in Cake.
    BookTitles

    Scaffold in being added also.(This is older version, I have not moved it to the trunk and begun to refactor yet)
    Scaffold Example
    /**
    * @author Larry E. Masters aka PhpNut
    * @url CakePHP Rapid Development Framework
    */

  9. #9
    SitePoint Enthusiast
    Join Date
    Mar 2004
    Location
    Shorewood, IL
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by meryn
    Sweatje, 1phpnut: thanks for the pointers to CakePHP. I'll take a look.
    No Problem.
    The development site is using Trac and is located here.
    CakePHP Development Site

    The site is using a SSL cert from here CaCert
    Which offers free (as in beer)SSL certs. If you get a popup about an invalid cert, follow the link at the bottom of the page to explain how to accept the root ca. That is if you plan to visit the site often.
    /**
    * @author Larry E. Masters aka PhpNut
    * @url CakePHP Rapid Development Framework
    */

  10. #10
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Location
    Bath, UK
    Posts
    2,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by 1PhpNut
    But show me something that can be done RoR, that can not be done in PHP?
    Code:
    $ script/console
    I think you've got the wrong end of the stick when you say "something impossible, not something easier". It is all about easier. Take the Perl on Rails* code. It isn't that it is impossible to do in Perl, it is just that it is so much easier in Ruby. You can't cast it off and argue that the extra complexity with using PHP over Ruby can be pushed into the framework, because the person writing the application still has to write PHP.

    * I would have used an example from Cake, but couldn't find an example app. A video like this one would be helpful there.

    For an ActiveRecord library, the one I've been pointing people to is the one here.

    Douglas
    Hello World

  11. #11
    SitePoint Zealot
    Join Date
    Mar 2004
    Location
    Netherlands
    Posts
    138
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It is all about easier.
    I think that's correct when talking about a RAD framework like Rails.

    Code:
    class Category < ActiveRecord::Base
       validates_length_of :category, :within => 1..20
       validates_uniqueness_of :category, :message => "already exists"
     end
    could be

    PHP Code:
    class Category extends ActiveRecord {
       var 
    $validates_length_of = array("category""within" => "1..20")
       var 
    $validates_uniqueness_of = array("category""message" => "already exists");

    In the PHP case, the string "1..20" should be parsed to some sort of array or object representing the 1..20 sequence. This would be some extra work for the framework, but it doesn't really complicate the API.

    I'm sure a PHP clone of rails would be somewhat heavier because of this, but in calling the framework, it won't make much of a difference.

    It would be nice if a CakePHP developer could contribute to this discussion.

  12. #12
    SitePoint Enthusiast
    Join Date
    Mar 2004
    Location
    Shorewood, IL
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by meryn
    I think that's correct when talking about a RAD framework like Rails.

    Code:
    class Category < ActiveRecord::Base
       validates_length_of :category, :within => 1..20
       validates_uniqueness_of :category, :message => "already exists"
     end
    could be

    PHP Code:
    class Category extends ActiveRecord {
       var 
    $validates_length_of = array("category""within" => "1..20")
       var 
    $validates_uniqueness_of = array("category""message" => "already exists");

    In the PHP case, the string "1..20" should be parsed to some sort of array or object representing the 1..20 sequence. This would be some extra work for the framework, but it doesn't really complicate the API.
    Close meryn,

    But in CakePHP it would be like this.
    I assume category is validating the name of the category?
    Correct me if I am wrong so I could fix this example:
    PHP Code:
    <?php
       
    class Category extends AppModel {
           var 
    $validate = array('name' =>array(VALID_UNIQUENESS_OF => "Category Name already exists"),
                                               
    VALID_RANGE_LENGTH => array("Category Name must be between 1 and 20 characters"120) );
    }
    ?>
    Quote Originally Posted by meryn
    I'm sure a PHP clone of rails would be somewhat heavier because of this, but in calling the framework, it won't make much of a difference.

    It would be nice if a CakePHP developer could contribute to this discussion.
    meryn,

    I am the same person who is doing a lot of commits to the CakePHP subversion repository.
    /**
    * @author Larry E. Masters aka PhpNut
    * @url CakePHP Rapid Development Framework
    */

  13. #13
    SitePoint Zealot
    Join Date
    Mar 2004
    Location
    Netherlands
    Posts
    138
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am the same person who is doing a lot of commits to the CakePHP subversion repository.
    Now isn't that a coincidence?

    So, from CakePHP's about page, I understand you're more or less cloning Rails. I actually think that's very smart, because Rails seems to have a good architecture with proven flexibility.

    Do you have some kind of overview of the current Rails features (from CakePHP's perspective) and which ones are filled by CakePHP, and to what extend? What I mean is your 'coverage'.

    Where are you now?
    50% of the whole Rails?
    80% of 'the good stuff'?

  14. #14
    SitePoint Enthusiast
    Join Date
    Mar 2004
    Location
    Shorewood, IL
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by DougBTX
    Code:
    $ script/console
    I think you've got the wrong end of the stick when you say "something impossible, not something easier". It is all about easier. Take the Perl on Rails* code. It isn't that it is impossible to do in Perl, it is just that it is so much easier in Ruby. You can't cast it off and argue that the extra complexity with using PHP over Ruby can be pushed into the framework, because the person writing the application still has to write PHP.
    I for one am very comfortable writting an application in PHP.
    Would be just as comfortable writting it in Ruby.

    My point is that MiiJaySung saying any of these applications similar to RoR...
    ...but I doubt you will find the ports half as good as the original rails. The reason being is that Rails exploits a lot of Ruiby-specific language features.
    Is not so true, maybe for MiiJaySung that is the case, but this had nothing to do with the question of the original post. And someone who is more comfortable writting PHP than they are Ruby would find this statement to be false also.

    meryn asked if there was a PHP alternative for Ruby on Rails, and there is.
    Quote Originally Posted by DougBTX
    [code]
    * I would have used an example from Cake, but couldn't find an example app. A video like this one would be helpful there.

    For an ActiveRecord library, the one I've been pointing people to is the one here.
    Douglas
    PHP Code:
       class Category extends AppModel {
           var 
    $validate = array('name' =>array(VALID_UNIQUENESS_OF => "Category Name already exists"),
                                               
    VALID_RANGE_LENGTH => array("Category Name must be between 1 and 20 characters"120) );


    When I get time I will put together a video too. Right now I am trying to get some unit test wrote since taking over a large portion of this development. And also implementing some things I feel are most important in the core for now.
    /**
    * @author Larry E. Masters aka PhpNut
    * @url CakePHP Rapid Development Framework
    */

  15. #15
    SitePoint Enthusiast
    Join Date
    Mar 2004
    Location
    Shorewood, IL
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by meryn
    Now isn't that a coincidence?
    You think so?

    Do you have some kind of overview of the current Rails features (from CakePHP's perspective) and which ones are filled by CakePHP, and to what extend? What I mean is your 'coverage'.
    A few people have stepped up to work on putting something together for this:
    Overall Strategy

    Where are you now?
    50% of the whole Rails?
    80% of 'the good stuff'?
    In comparison to what you can accomplish with it I would say it is about 20% whole Rails have not really tried to figure that number out for sure though. I have been refactoring code, and rewritting test that needed work also.
    /**
    * @author Larry E. Masters aka PhpNut
    * @url CakePHP Rapid Development Framework
    */

  16. #16
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Location
    Bath, UK
    Posts
    2,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by 1PhpNut
    In comparison to what you can accomplish with it I would say it is about 20% whole Rails have not really tried to figure that number out for sure though. I have been refactoring code, and rewritting test that needed work also.
    Actually, that's probably a bigger issue than the Ruby vs PHP one: time. Rails is comming up for the big 1.0, the translations are really just getting started. I've not seen any real applications written using Rails-translation frameworks, while Rails was being used in programs like Instiki before it was even called Rails.

    The validation example does demonstrate how Rails plays to the advantages in Ruby. With this code:

    Code:
    class Category < ActiveRecord::Base
      validates_length_of :category, :within => 1..20
      validates_uniqueness_of :category, :message => "already exists"
    end
    The validation calls are just plain method calls, there isn't anything special going on. With the PHP code you posted, you've got to build up a three dimensional array by hand, and there is no obvious way to make, say, messages optional. With Ruby 1.9, you can even skip the extrenious => arrows:

    Code:
    class Category < ActiveRecord::Base
      validates_length_of :category, within: 1..20
      validates_uniqueness_of :category, message: "already exists"
    end
    It is even harder to translate things like this:

    Code:
    class Person < ActiveRecord::Base
      validates_each :first_name, :last_name do |record, attr|
        record.errors.add attr, 'starts with z.' if attr[0] == ?z
      end
    end
    Getting the Rails production environement is an even bigger technical challange, even the idea of one for PHP has been shouted down on these forums, on the grounds that it isn't like PHP. I assume the easiest way would be to just cache things like the database reflection data between requests, but it is going to be more work. With Rails, you just run it under FastCGI, sorted. Things like the interactive console are even harder, but for Rails it is just an extension to the bundled interactive Ruby console.

    But hay, you said things which were impossible, not things which are harder

    Douglas
    Hello World

  17. #17
    SitePoint Zealot
    Join Date
    Mar 2004
    Location
    Netherlands
    Posts
    138
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It is even harder to translate things like this: ...
    Hmm yeah I see Ruby has some very powerful language constructs. Totally different than the 'C' based languages. Equivalent PHP code would be much more verbose than that.

    Getting the Rails production environement is an even bigger technical challange
    What do you mean by that? You could run a command line PHP script to do code generation. I don't see why that would be more un-PHP-like than un-Ruby-like.

    The thread you mention is more about some sort of 'generic' application server, and I don't see any need for that. IMO, a script in a apache accessible directory is like a servlet in a servlet mapping. Apache+PHP is the script container.

    An interactive console isn't an option I think, but I don't see that as a core competency of Rails. For simple db-edits you can use phpMyAdmin, and for complex ones a command line php script (which would need to include the framework bootstrapping file).

  18. #18
    throw me a bone ... now bonefry's Avatar
    Join Date
    Nov 2004
    Location
    Romania
    Posts
    848
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The thread you mention is more about some sort of 'generic' application server, and I don't see any need for that. IMO, a script in a apache accessible directory is like a servlet in a servlet mapping. Apache+PHP is the script container.
    Yes, well, the script container you are talking about is process based. It can't do multiple threads, it can't run for a very long time and it can't have persistance without serializing/deserializing the objects. They don't call them application servers for nothing you know.
    It is even harder to translate things like this: ...
    PHP lacks some of the features scripting languages have had for years. But I wouldn't choose Ruby because after 10 years it's still imature and I'm sick of old and imature languages . Latelly I discovered Python and I am quite impressed. Those constructs you are talking about are a breeze in Python. So it has the potential to come up with something better than Rails. Plus, I heard good things about Zope.
    What wonders can a 10 minute movie do !

  19. #19
    SitePoint Wizard DougBTX's Avatar
    Join Date
    Nov 2001
    Location
    Bath, UK
    Posts
    2,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by meryn
    What do you mean by that? You could run a command line PHP script to do code generation. I don't see why that would be more un-PHP-like than un-Ruby-like.
    Oh, I didn't mean that. Rails has three "environments" by default: development, testing and production. With development, it reloads the whole app each request, much like with PHP. In the production environment, it keeps things like the database structure in memory (things which stay the same for every request) so that it doesn't have to ask the database "which fields are in the users table again?" each time you load a page. It isn't the Java application server model though, it is still a processes based architecture, no fiddling about with threads. It is just less to reload per request.

    But I wouldn't choose Ruby because after 10 years it's still imature and I'm sick of old and imature languages
    I'm not really sure what you mean by immature. Probably the least mature part would be documentation, though that is changing. That Ruby is even being talked about in the English speaking world now is a sign that the new documentation is heading in the right direction. Rails is documented fully in English.

    And as for not liking old languages, Python is older than Ruby I don't keep much track of the Pythion world, but I do know work is being done to combine existing Python libraries to make them work as well together as Rails does. Take a look at Subway. When googleing for Subway, I saw this article which suggests why copying Rails won't work from a social point of view. The idea is that people are drawn to Rails because of what it offers, not because it is written in Ruby. So, the theory goes, people won't be (as) attracted to a second Rails framework because it is written in X language, because they were language agnostic to start with.

    Having said that, after learning Ruby, I am even more interested in learning the other very-OO languages, like Python and Smalltalk. Now getting really off topic, how much work is being done on VMs for Python? I know the current one is more advanced that the Ruby one, as it can already compile to bytecode. I've heard of people trying to port Ruby to the Smalltalk VMs (which could be very interesting) and the somewhat-vaporish Perl 6 Parrot VM. Always lots of interesting things happening outside PHP, while we still struggle with references and temporary variables and object comparison and magic quotes and...

    Later,
    Douglas
    Hello World

  20. #20
    SitePoint Guru 33degrees's Avatar
    Join Date
    May 2005
    Posts
    707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by bonefry
    But I wouldn't choose Ruby because after 10 years it's still imature and I'm sick of old and imature languages .
    Why do you consider Ruby to be imature? You've said this before, but never explained why?

    Quote Originally Posted by meryn
    MiiJaySung, what kind of language features would that be?
    Maybe you know RoR better than me... I don't have hands on experience with it, and also haven't examine the source yet. I just read a lot of tutorials, watched some moviews, and was impressed.

    Do you think the Rails API would be much harder to implement in PHP then it is in ruby?
    I've been studying Ruby and poking through the rails source a fair bit lately; nothing I've seen so far would be impossible to recreate in PHP, but much of it would take a fair amount of extra code to implement. Rails makes extensive use of Ruby's metaprogramming features; which on top of reducing the amount of code written, makes the framework feel like a part of the language. But much of Rails' appeal is in it's approach, and that is something to can translate to other languages quite well.

  21. #21
    SitePoint Enthusiast
    Join Date
    Mar 2004
    Location
    Shorewood, IL
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by 33degrees
    ...But much of Rails' appeal is in it's approach, and that is something to can translate to other languages quite well...
    Agree 100%
    /**
    * @author Larry E. Masters aka PhpNut
    * @url CakePHP Rapid Development Framework
    */

  22. #22
    throw me a bone ... now bonefry's Avatar
    Join Date
    Nov 2004
    Location
    Romania
    Posts
    848
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    And as for not liking old languages, Python is older than Ruby I don't keep much track of the Pythion world, but I do know work is being done to combine existing Python libraries to make them work as well together as Rails does. Take a look at Subway. When googleing for Subway, I saw this article which suggests why copying Rails won't work from a social point of view.
    All existing and succesfull languages are at least 10 years old. I know that. But I said I don't like old and imature languages. And Python is not imature.
    That article is just Python bashing. Zope is actually good, although they have been copying the Java way. But it's one of the reasons people learn Python (just like people are learning Ruby for RoR).

    I took a look at Ruby on Rails yesterday and it's actually quite good. But not that original. It's ideeas are based on principles that have been around in Python's and Perl's worlds for quite some time. The only ?good? thing about it is that it's a meta-framework. That means you don't have to combine pieces made by different programmers to make something. This is what made .NET more attractive. And this kind of meta-frameworks are the future. But soon all the HYPE around RoR will be gone, and it remains to be seen if it holds its ground. Because there can't be a single answer for everything. We all want choice. And soon people are going to provide alternatives to RoR in Ruby. And yet again, Ruby will be considered bloated just like Python and Java are considered right now. It won't be fair when another language comes along that says it has a cleaner architecture.
    PS: Since Microsoft doesn't give a f*ck on braking backwards compatibility, it's kind of dangerous in the long run.

    Quote Originally Posted by 33degrees
    Why do you consider Ruby to be imature? You've said this before, but never explained why?
    Ok, I don't want to upset anybody. I am thinking more on commercial side of things. We all have to eat . How many projects are made in Rails ? How many people choose Rails over Java or PHP or Python or Perl (I know there are some, but not enough). Of course, it has gathered a wonderfull comunity around allready. And that's very good. And maybe in 2 years from now, Ruby will be quite attractive for business. But right now it's not. And that's imaturity (unless proven wrong a language is considered imature from the start).

  23. #23
    SitePoint Zealot
    Join Date
    Jul 2005
    Posts
    194
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Beside that I just don't like the syntax of Ruby. It's just plain ugly

  24. #24
    SitePoint Zealot
    Join Date
    Mar 2004
    Location
    Netherlands
    Posts
    138
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In the production environment, it keeps things like the database structure in memory
    How does it do that? I think you could do the samen with e-accelerator. AFAIK Mmcache allowed you to store shared variables in memory, so I guess e-accelerator does too.

    (things which stay the same for every request) so that it doesn't have to ask the database "which fields are in the users table again?" each time you load a page.
    And that would be considered not PHP-like by some? I'm just trying to follow the logic.

    Even without sharing variables between processes you could do some code generation based on the db-layout. The framework could check wether this 'cache' file exist, and if so, skip the database inspection step, and just load that file.

    BTW, the main reason I think there should be a PHP clone of Rails is not that I consider Ruby immature or something, but that PHP has so much higher support among webhosts. Deploying Ruby applications would mean switching webhosts, for most web programmers (who statistically probably use PHP).

    One could argue that the 'best'/'leading' developers are more evenly spread across platforms (.NET,Java,PHP,Python,Perl,Ruby). Nonetheless a good PHP clone would have tremendous value, IF it's accepted by the community.

  25. #25
    throw me a bone ... now bonefry's Avatar
    Join Date
    Nov 2004
    Location
    Romania
    Posts
    848
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Everyone says Ruby on Rails is elegant because it's implemented in Ruby. And I won't deny it. But one of the reasons it's so elegant it's because, instead of writting miles of XML config files (Java like) it relies on reflection and conventions. And that can be very well replicated in any dynamic language. PHP is a very good candidate. Python too. Don't know about Perl, probably. But it can be done even in Java. In fact all languages that have reflection.
    And Cake PHP has potential.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •