#1
  1. No Profile Picture
    Dazed&Confused
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2002
    Location
    Tempe, AZ
    Posts
    506
    Rep Power
    128

    Global & Static Scope vs. Zend "Application"


    In my nightmare that is Zend, we had a call with some of their representatives about migration strategies, and my boss asked what the benefits of ZF2 are over ZF1.

    They stated that ZF2 follows modern "best practices" of getting away from global scope objects, functions, and variables.

    But the more I thought about this the more it seemed misleading. Everything within the Zend framework, and anything you integrate into it, runs under the scope of their Application class. And anything under that scope can access the configuration, events, services, requests, responses, etc., just as a conventional application could access those things from the global scope.

    So my question is simple: How is their "application scope" any different in concept than PHP's default "global scope"?

    It seems like the very same thing in practice, just shifted down into an object. And if that is thee defining difference, what makes that fundamentally "better"?

    Because I'm just finding it to be a pain in the rear. Of course, I think I'm resistant to any framework that inherently limits the flexibility of PHP. If I wanted a limited environment I'd be programming Java...
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    101
    Rep Power
    27
    Is it possible they're simply referring to the addition of namespaces, which was introduced in 5.3? Pretty sure ZF2 requires at least 5.3 and makes extensive use of namespaces. The point of namespaces is that you don't pollute the top-level scope with every single function or class you create, instead you have modular or component-like organization of code.
  4. #3
  5. No Profile Picture
    Dazed&Confused
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2002
    Location
    Tempe, AZ
    Posts
    506
    Rep Power
    128
    Originally Posted by mod_speling
    Is it possible they're simply referring to the addition of namespaces, which was introduced in 5.3? Pretty sure ZF2 requires at least 5.3 and makes extensive use of namespaces. The point of namespaces is that you don't pollute the top-level scope with every single function or class you create, instead you have modular or component-like organization of code.
    Na, they're referring to having to use heavy injection in order to get their scope into your own code, as the means of integrating with Zend.

    For instance, in Zend 1 there was a call like:

    PHP Code:
    $adapter Adapter::getDefaultAdapter(); 
    Our code could use that anywhere to get the MySQL adapter that was configured within Zend.

    In order to get the adapter into our code now, I have to pass the Zend application object (or a subset of it) into our methods and then pull the adapter from that.

    It seems to go with the premise that injection is better than global scope, even if that means all you're doing is injecting their scope all over the place.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    101
    Rep Power
    27
    I see. Well I think those guys believe hard in the ultimate utility of dependency injection and IOC, trying for 100% testable code coverage and loose coupling and those sort of ideals. You're gonna have to drink the kool-aid if you want to roll forward with ZF.
  8. #5
  9. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,316
    Rep Power
    7171
    If you're thinking about migrating from ZF1 to ZF2 I would advise against it unless you're planning a complete rewrite of the application.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  10. #6
  11. No Profile Picture
    Dazed&Confused
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2002
    Location
    Tempe, AZ
    Posts
    506
    Rep Power
    128
    Originally Posted by E-Oreo
    If you're thinking about migrating from ZF1 to ZF2 I would advise against it unless you're planning a complete rewrite of the application.
    Not much choice in a professional environment. They're going to be ceasing support of ZF1 early next year. I was tasked with assessing what'd take to convert (which is odd since I knew neither one) and pretty much came up with the same conclusion.

    So we had that call with the Zend people and I pointed out the two biggest obstacles I thought we'd have, and they agreed that they were two of the worst. Go figure.

    But we don't have the resources to convert, so we're probably going to outsource it.

    Personally I see it as an opportunity to ditch these framework monstrosities that leave you reliant on third parties, but the boss disagrees.
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    101
    Rep Power
    27
    They're going to be ceasing support of ZF1 early next year
    ... And? I mean, in some sense if you continue with your application as-is and don't upgrade, you're internalizing support (which you'd be doing if you rolled your own framework, or outsourced the work of building something entirely new). Weigh that internal maintenance and support cost over the next 3-4 years against the cost of outsourcing to refactor your codebase for ZF2, and tell me it isn't pretty close.
  14. #8
  15. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,316
    Rep Power
    7171
    They're going to be ceasing support of ZF1 early next year.
    Do you upgrade your application framework whenever they release an update to it? The application isn't going to stop working when the framework isn't supported anymore.

    Doing a complete application rewrite is a huge business risk, particularly if you outsource the work to someone who isn't familiar with your current application or business. Doing a rewrite of an application is also a huge cost. Plus, if you don't use a framework you will be substantially increasing both the risk and the cost. Combine that with the fact that if your application is currently working well, then switching from ZF1 to ZF2 has very little, if any, benefit to the business.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  16. #9
  17. No Profile Picture
    Dazed&Confused
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2002
    Location
    Tempe, AZ
    Posts
    506
    Rep Power
    128
    Originally Posted by E-Oreo
    Do you upgrade your application framework whenever they release an update to it? The application isn't going to stop working when the framework isn't supported anymore.
    Well, personally I avoid the problem altogether by not using them. As I implied, I don't like the roadmaps of my projects being at the mercy of third party development I have no control over.

    But from a business perspective and the fact they insist on using Zend, I agree with the upgrade. It's the same reason I can see a business not wanting to use unsupported versions of Windows. If a security flaw is found and the software isn't supported anymore, there won't be a patch.

    Plus the application isn't that big; only 35k lines of code. My personal CMS software that I've built up alone is over twice that.
  18. #10
  19. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,316
    Rep Power
    7171
    It's the same reason I can see a business not wanting to use unsupported versions of Windows.
    Hm, I disagree with that comparison. I understand the security aspect, but there are some pretty large differences between an unsupported version of Windows and an unsupported PHP framework. First and foremost is the fact that ZF is open source and Windows is not. Additionally the code for a PHP framework is lot less complicated and a lot less extensive than the code for an operating.

    Third parties will continue to issue security bulletins for ZF even after Zend discontinues official support. There may not be official patches for them, but monitoring those and patching any identified issues would not be very challenging, particularly because ZF is a pretty secure framework already and has very few security bulletins issued for it.

    The smaller the application is the less risk and cost is involved in upgrading obviously, so that's a good thing to look at. 35k isn't very big, although it's not trivial either.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  20. #11
  21. No Profile Picture
    Dazed&Confused
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2002
    Location
    Tempe, AZ
    Posts
    506
    Rep Power
    128
    Originally Posted by E-Oreo
    Hm, I disagree with that comparison. I understand the security aspect, but there are some pretty large differences between an unsupported version of Windows and an unsupported PHP framework. First and foremost is the fact that ZF is open source and Windows is not. Additionally the code for a PHP framework is lot less complicated and a lot less extensive than the code for an operating.
    Granted, but none of us know Zend particularly well and if we have to learn a version it'd be more cost-effective to learn ZF2. Plus I don't know how good we'd be about keeping up with third party notices of problems.

    In any case, the call was made and it's happening whether I like it or not.

IMN logo majestic logo threadwatch logo seochat tools logo