HMVC and Cjax |
[eluser]Fredrik-s[/eluser]
Hello, I have googled a lot and read threads regarding getting HMVC and Cjax to work properly. Although there isn't any good documentation covering how to install Cjax with an HMVC CodeIgniter installation structure. My setup looks like this: - CodeIgniter 2.1.4 - HMVC (https://bitbucket.org/wiredesignz/codeig...sions-hmvc) - Cjax 5.8 - Friendly URLS - mapped to cached route.php-file under "application/cache" .htaccess Code: <IfModule mod_rewrite.c> File structure: /ajax.php /ajaxfw.php /cjax/ /application/response/sample.php /application/response/test.php /application/controllers/AjaxController.php Also tested to create a test module like the following /application/modules/test/controllers/test.php /application/modules/test/models/ /application/modules/test/views/ Put the following in my cached routes.php-file (application/cache/routes.php) $route['test'] = 'test'; $route['test/test'] = 'test'; $route['test/test2'] = 'test'; When surfing to http://example.com/ajax/test/test2 i get the following message stating my routes aren't right: Unable to load your default controller. Please make sure the controller specified in your Routes.php file is valid. What am I doing wrong and how should I fix it?
[eluser]jonez[/eluser]
Not to disrespect the author of Cjax or the author of this thread but you really shouldn't use a library like that. JS has no place in PHP code for many reasons (breaks MVC methodology, limits your understanding of JS and AJAX, locks your front end into CI, etc). I'm really not sure why CI has a JS library at all it should be removed from the framework.
[eluser]Unknown[/eluser]
If you put JS and Ajax on your CI views, it's the same as using Cjax in views, some kind of helper which helps you with ajax code development.
[eluser]jonez[/eluser]
The JS library was just deprecated in CI3. Code: * @category Javascript Code: ====================== I've never used Cjax to know what implications this has for that library.
[eluser]InsiteFX[/eluser]
Also HMVC will not work in the CI Dev 3.0 because all the methods are now protected.
[eluser]jonez[/eluser]
[quote author="InsiteFX" date="1392049437"]Also HMVC will not work in the CI Dev 3.0 because all the methods are now protected. [/quote] They've changed quite a bit that HMVC probably overloads so it will need to be updated. You can overload protected method's, I have my own version of HMVC done through core extensions.
[eluser]InsiteFX[/eluser]
The point is how many more backwards libraries etc; are they going to break? This is why half of the community has already left Codeigniter for other frameworks. The best thing for CI is for them to start from scratch and build a new PHP 5 HMVC framework that is up to date, instead of trying to patch this one up.
[eluser]jonez[/eluser]
[quote author="InsiteFX" date="1392058495"]The point is how many more backwards libraries etc; are they going to break? This is why half of the community has already left Codeigniter for other frameworks.[/quote] Any library that's overloading core functionality should expect to require modifications when a new version is released. You can't avoid that in any framework. If they had used private instead of protected it would be bad, but protected vs public shouldn't cause a problem. From what I've seen they've split a lot of large core methods into pieces so it's actually easier to overload in CI3. The last router update they made reduced my controller suffix mod from two pages to less than 40 lines. [quote author="InsiteFX" date="1392058495"]The best thing for CI is for them to start from scratch and build a new PHP 5 HMVC framework that is up to date, instead of trying to patch this one up.[/quote] Wouldn't that be worse? If they did that no existing libraries would work they'd all require rewrites. There are some neat features in the more recent versions of PHP but there isn't anything you can't do today albeit in a more roundabout way. Namespaces (if I needed them but I don't) is about the only feature I can think of that would necessitate using another framework. Everything else is just a newer way to do the same thing. If they did do a rewrite it would alienate all the existing users and for what? There's already 5+ other frameworks out there that fit that bill. If you're concerned about being 'modern' you should try Node not another PHP framework. Backends are becoming increasingly unimportant, and offline first will be the next iteration of web applications. That's my plan in the long run, today CI isn't much more than a rest server that handles API's. Users only care about the experience not what's under the hood (PHP, Ruby, Python, it doesn't really matter).
[eluser]Ajaxboy[/eluser]
Sorry to jump in into this conversation to late. I'll address a couple of posts from this thread, first answer the original question: This question has been asked before. I never used the HMVC library personally, and never took the time to test with it, hence there is no built it compatibility into Cjax (Can't say if there is or not built-in compatibility into HMVC) - so if any working integration with the two libraries exists, it doesn't come from built-in into Cjax. so if there is a working integration it would of been from other sources. Although speculative, if any changes need to made from Cjax I think it would be in from ajax.php (the only file that holds any changes to integrate cjax into codeIgniter, in addition to AjaxController.php) @jonez, Second, to address the response from jonez, 1. No Cjax does not have any dependencies on any JS library, or any other dependencies whatsoever. (Cjax has it's own) 2. "JS has no place in PHP code", Cjax is not just any JS library. It is a ecosystem of finely built integration of PHP bridge for JS. There is no actual JS code inside your PHP, It is 100% PHP. So I think you should take your time to investigate a little. |
Welcome Guest, Not a member yet? Register Sign In |