Wednesday, July 31, 2013

Re: Wordpress blog archive look like in CakePHP

One way to approach this is to use a virtual field (http://book.cakephp.org/2.0/en/models/virtual-fields.html). In your Post model, create a virtual field called year that gets the year out of the created field.

On Tuesday, July 30, 2013 4:19:54 PM UTC-7, Helder Lucas wrote:

I'm building and application with cakePHP and I'm trying to achieve something like a Wordpress blog archive.

Let's imagine that i have this table in my database:

  • Posts
    • id
    • title
    • body
    • created
    • modified

and i want the output something like this:

<h1>2013</h1>
     <p>Post Title</p>
     <p>Post Title</p>
     <p>Post Title</p>

<h1>2012</h1>
     <p>Post Title</p>
     <p>Post Title</p>
     <p>Post Title</p>

etc etc     

I have searched and tried by myself but unfortunately with no success.

Thanks in advance.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Re: Odd issue with beforeFilter()


Okay..If anyone else has this issue, here is the solution to my particular problem.  I created an element 't_rt_keyhole' , which uses the requestAction to return data, in one of my views.  The troublesome line is:

$this->requestAction('/page_key_holes/keyhole/'.$pageid.'/'.$templateid);

Since this action uses a view of "keyhole" my before filter was not allowing the page.  Simply adding keyhole to me beforefilter did the trick:

function beforeFilter() { parent::beforeFilter(); $this->Auth->allow('view', 'keyhole'); }

Hope this helps others.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Re: Dealing with big cakephp applications

Hi, Diogo.

If your aim is to separate the models from the controllers, views, etc., then Cake can handle that.  I haven't tried this yet, but I was looking at the possibility of splitting off the back-end functions of my app to a separate app on a sub-domain.  From there I can either link to the models in in the main app, or split the models off into their own "app" just for modularity.  Like Reuben said, plugins would also help to avoid redundant code between apps.

The Cookbook shows you here http://book.cakephp.org/2.0/en/core-utility-libraries/app.html, in the section titled "Adding paths for App to find packages in" how to direct Cake to another directory containing the Models to be used by your app (theoretically, the same would apply for other Cake classes, like controllers, views, etc.).

Like I said, I haven't tried this yet, so I am not sure if there are any practical issues to be resolved.

Good luck.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Re: jquery/mobile

Awfully vague question.

Also, doesn't sound like it's a CakePHP issue. You should rephrase
your question for the jQuery Mobile community.

On Wed, Jul 31, 2013 at 2:43 PM, L2 G <l2g95051@gmail.com> wrote:
> we are trying to use cakephp+jquery/mobile. We have issues using infinite
> scrolling in the mobile web. We have setup separate themes and such.
> everything works ok on browser version. on mobile all the jquery
> functionality fails only the first 2 items ( the first rows are ok) and once
> we scroll and ajax call kicks in, it all starts to fail.
>
> --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to cake-php+unsubscribe@googlegroups.com.
> To post to this group, send email to cake-php@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



--
Simon Males

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

is it possible in cakephp to access directory outside of app

I want to access folder outside the app directory for different web application

my folder structure is like

/public_html/app  /public_html/application1  /public_html/application2

Url I want is like mydomain.com for app

mydomain.com/application1 for application1

mydomain.com/application2 for application2


--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Odd issue with beforeFilter()

Greetings! 

I am using the Alaxos ACL plugin - which, is pretty awesome.  The only issue I am having, and I haven't had on any of my other applications is with beforeFilter().

In my AppController I have the following:

function beforeFilter() { parent::beforeFilter(); $this->Auth->allow('index'); }

This seems to work without any issue.  When viewing any index the application allows the view - and on any other action redirects to the login action.  However, I don't want to allow any of the index actions, rather I only want to show the 'view' actions.  Seem easy right? 

But, alas, if I change this line to:

function beforeFilter() { parent::beforeFilter(); $this->Auth->allow('view'); }

I am redirected to the login action for all actions.

What the heck am I doing wrong?  I have been struggling with this for two days.  Help is greatly appreciated.

Thanks!

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Tuesday, July 30, 2013

jquery/mobile

we are trying to use cakephp+jquery/mobile. We have issues using infinite scrolling in the mobile web. We have setup separate themes and such. everything works ok on browser version. on mobile all the jquery functionality fails only the first 2 items ( the first rows are ok) and once we scroll and ajax call kicks in, it all starts to fail.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Problem with install cakephp 2.3.8 in System OS/400 Power 7

Hi all, please help  with error in cakephp 2.3.8 my default page into a fresh instalation of cakephp in a System OS/400 Power7 report the next error:
FileEngine Object
[_File:protected]=> SplFileObject Object
error complete here:

PHP VERSION: 5.4.16
APACHE VERSION: 2.2.11
CAKEPHP VERSION: 2.3.8

The owner the directory app/tmp is the owner the apache server, the permisions the tmp is correct.

Thank for your time!!

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Wordpress blog archive look like in CakePHP

I'm building and application with cakePHP and I'm trying to achieve something like a Wordpress blog archive.

Let's imagine that i have this table in my database:

  • Posts
    • id
    • title
    • body
    • created
    • modified

and i want the output something like this:

<h1>2013</h1>
     <p>Post Title</p>
     <p>Post Title</p>
     <p>Post Title</p>

<h1>2012</h1>
     <p>Post Title</p>
     <p>Post Title</p>
     <p>Post Title</p>

etc etc     

I have searched and tried by myself but unfortunately with no success.

Thanks in advance.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Re: 2.3 Checkbox validation

Why are you not using 0/1 (the numeric representation of boolean false/true) here?
Would make your life so much easier. And the validaiton rule here.

Also, boolean checkboxes by default would use those values anyway if you let them.



Am Dienstag, 30. Juli 2013 18:14:53 UTC+2 schrieb Eric Haskins:
Ok I must be doing something wrong on my checkbox validation because its always invalid

Snip of validation:

'agever' => array(
'notEmpty' => array(
   'rule' => array('equalTo', 'yes'),
   'required' => true,
   'message' => 'We require you to be over 13 to register without a Parent.'
)
   ),
   'agreeterms' => array(
'notEmpty' => array(
   'rule' => array('equalTo', 'yes'),
   'required' => true,
   'message' => 'Please Agree to the Terms if you want to proceed.'
)
   ),


part of the form

echo $this->Form->input('agever',array('type'=>'checkbox','value'=>'yes','label' =>'Are you over the age of 13'));
echo $this->Form->input('agreeterms',array('type'=>'checkbox','value'=>'yes','label' => 'I agree to the <a href="/terms" target="_blank">Terms & Conditions</a>'));

What the heck am I doing wrong here. 




--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

2.3 Checkbox validation

Ok I must be doing something wrong on my checkbox validation because its always invalid

Snip of validation:

'agever' => array(
'notEmpty' => array(
   'rule' => array('equalTo', 'yes'),
   'required' => true,
   'message' => 'We require you to be over 13 to register without a Parent.'
)
   ),
   'agreeterms' => array(
'notEmpty' => array(
   'rule' => array('equalTo', 'yes'),
   'required' => true,
   'message' => 'Please Agree to the Terms if you want to proceed.'
)
   ),


part of the form

echo $this->Form->input('agever',array('type'=>'checkbox','value'=>'yes','label' =>'Are you over the age of 13'));
echo $this->Form->input('agreeterms',array('type'=>'checkbox','value'=>'yes','label' => 'I agree to the <a href="/terms" target="_blank">Terms & Conditions</a>'));

What the heck am I doing wrong here. 




--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

CURL post fields and empty data

Hi everybody. I'm getting crazy with a very small webservice. From client side I'm making a POST request with cURL, sending a post field called userid.
Something like:
CURLOPT_POSTFIELDS => array('loginid' => 'MyLoginData123').
On the server side, $this->request->data is empty since the request is not coming from a cakephp form. $_POST is also empty, maby cleared by cakephp.
The previous solution (valid in older versions of cakephp) to access external from data with $this->params['form'] isn't valid anymore.
Doing a debug($this->request) i get this:
object(CakeRequest) {
params => array(
'plugin' => null,
'controller' => 'links',
'action' => 'getclientlinks',
'named' => array(),
'pass' => array(),
'isAjax' => false
)
data => array()
query => array()
url => 'links/getclientlinks'
base => ''
webroot => '/'
here => '/links/getclientlinks'
[protected] _detectors => array(
'get' => array(
'env' => 'REQUEST_METHOD',
'value' => 'GET'
),
'post' => array(
'env' => 'REQUEST_METHOD',
'value' => 'POST'
),
'put' => array(
'env' => 'REQUEST_METHOD',
'value' => 'PUT'
),
'delete' => array(
'env' => 'REQUEST_METHOD',
'value' => 'DELETE'
),
'head' => array(
'env' => 'REQUEST_METHOD',
'value' => 'HEAD'
),
'options' => array(
'env' => 'REQUEST_METHOD',
'value' => 'OPTIONS'
),
'ssl' => array(
'env' => 'HTTPS',
'value' => (int) 1
),
'ajax' => array(
'env' => 'HTTP_X_REQUESTED_WITH',
'value' => 'XMLHttpRequest'
),
'flash' => array(
'env' => 'HTTP_USER_AGENT',
'pattern' => '/^(Shockwave|Adobe) Flash/'
),
'mobile' => array(
'env' => 'HTTP_USER_AGENT',
'options' => array(
(int) 0 => 'Android',
(int) 1 => 'AvantGo',
(int) 2 => 'BlackBerry',
(int) 3 => 'DoCoMo',
(int) 4 => 'Fennec',
(int) 5 => 'iPod',
(int) 6 => 'iPhone',
(int) 7 => 'iPad',
(int) 8 => 'J2ME',
(int) 9 => 'MIDP',
(int) 10 => 'NetFront',
(int) 11 => 'Nokia',
(int) 12 => 'Opera Mini',
(int) 13 => 'Opera Mobi',
(int) 14 => 'PalmOS',
(int) 15 => 'PalmSource',
(int) 16 => 'portalmmm',
(int) 17 => 'Plucker',
(int) 18 => 'ReqwirelessWeb',
(int) 19 => 'SonyEricsson',
(int) 20 => 'Symbian',
(int) 21 => 'UP\.Browser',
(int) 22 => 'webOS',
(int) 23 => 'Windows CE',
(int) 24 => 'Windows Phone OS',
(int) 25 => 'Xiino'
)
),
'requested' => array(
'param' => 'requested',
'value' => (int) 1
)
)
[protected] _input => '------------------------------1e37f69d3cc8
Content-Disposition: form-data; name="loginid"

MyLoginData123
------------------------------1e37f69d3cc8
Content-Disposition: form-data; name="userid"

MyUserData12345
------------------------------1e37f69d3cc8--
'
}


As you see I posted 2 fields (loginid and userid), but I can't access them.

Is there a way to access post data not originated by a cakephp form?

Thank you

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Re: hasMany / belongsTo not working

On Tue, Jul 30, 2013 at 6:50 AM, WhyNotSmile <sharongilmore78@gmail.com> wrote:
> I have a pretty simple pair of objects, Photo and Album, defined as follows:
>>
>> class Album extends Model {
>> public $name = 'Album';
>>
>> public $hasMany = array(
>> 'Photo' => array(
>> 'className' => 'Photo',
>> 'order' => 'Photo.order ASC'
>> )
>> );
>> }
>
>> class Photo extends Model {
>> public $name = 'Photo';
>> public $belongsTo = array('Album');
>> }
>
>
> I currently have 3 albums, one with 0 photos, one with 1 photo, and one with
> 2 photos. When I do the following in the controller, I expect to get 3
> albums back:
>
>> $albumlist = $this->Album->find('all');
>> debug($albumlist);
>
> But in fact, I get 4 - the one with 2 photos is shown twice. If I had
> another photo, I get the album back 3 times. I'm absolutely stumped as to
> what's causing this, and have a feeling it must be something really stupid
> that I've done. I've set up much more complex models than this in the past,
> with no problems.

Did you inserted the records using those CakePHP models?

Is your database modeled properly?

How the related SQL queries looks like in debug mode?

Check if you get the same information querying the database directly
with something like this (assuming the standard conventions) in your
SGBD query prompt.

SELECT p.*
FROM photos p INNER JOIN albums a
ON (p.album_id=a.id)

Assuming you followed the standard conventions and just for a debugging
purpose, try to simplify your associations and redo the tests.

// Album
public $hasMany = 'Photo';

// Photo
public $belongsTo = 'Album';

Hope it helps.

MARCELO DE FREITAS ANDRADE
https://mailstrom.co/mfandrade

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

Quick Newsletters | Twitter | SEO: Non-profits

  Cannot see this email? View in browser
 
Web Marketing Today
  July 30, 2013  
 
How to Write an Email Newsletter in 90 Minutes
Writing a newsletter is one of the most difficult marketing stumbling blocks for a small business owner. You know it's a task worth doing, but every week or month the email newsletter deadline rolls around and you think, "What I am going to say in the newsletter?" The good news is that if you can carve out even 90 minutes, you can get that newsletter done.
Read the Article
 
 
 
10 Ways to Build a Twitter Audience for your Business
Twitter is becoming ever more popular. Increasingly as important as a Facebook account, a Twitter account is made even more social by retweets, shared links, and sudden swells of memes, shared jokes or ideas. Twitter currently boasts roughly 200 million users. That number is growing. Like many social media platforms, marketing on Twitter needs...
Read the Article
 
 

- Advertisement -
 
Get More Leads - Identify Anonymous Visitors
Less than 2% of your site visitors will ever contact you. We identify the other 98%. No logins or form fill required. Our top 5 features are: (1) We identify who the visitor is; (2) Find their phone number; (3) Determine buying intent; (4) Deliver all of this information in real-time; (5) Offer a completely private/white label solution for your customers. 
Click Here for Free Trial
 
 
 
Local SEO for Non-profit Organizations
In many ways, non-profit organizations enjoy a high degree of trust from search engines. Websites with .org domains are less prone to do commercial link manipulation, and competition among non-profits is not as fierce as some other industries. Even so, non-profits that enjoy better search engine rankings likely gain greater market share in terms of...
Read the Article
 
 
 
Who Reads Web Marketing Today? 2013 Reader Survey
The goal of our August 2013 survey is to learn more about you, our reader. We do this periodically to help ensure our editorial content matches your needs. The survey consists of four quick multiple-choice questions. We ask about (a) your business, (b) your role within the business, (c) the size of your business, and (d) the importance of the local economy...
Read the Article
 
 

Law Blogs: Free Speech or Marketing?

8 Site Checks for Upcoming Busy Season

7 Keys to Facebook's 'People Talking About This'

7 Steps to Mobile-friendly Emails

9 Tips for Developing a Pinning Strategy

12 Web Design Trends for 2013

8 Tips to Manage Facebook More Effectively

10 Mapping Tools for Local Websites

AdWords Editor: Top Timesaving Tips

Time to Revamp your Local Website?

 
Share: Twitter Facebook


Web Marketing Today®
518 28 Road, Suite B-203, Grand Junction, CO, 81501, U.S. 970-257-0606
Contact Us

Copyright © 2013 Web Marketing Today. All rights reserved.
Please do NOT reprint or host on your website without explicit permission.
 

 

If you do not wish to receive mail from us, please click here to unsubscribe .

hasMany / belongsTo not working

I have a pretty simple pair of objects, Photo and Album, defined as follows:
class Album extends Model {
    public $name = 'Album';

public $hasMany = array(
'Photo' => array(
'className'     => 'Photo',
'order'     => 'Photo.order ASC'
)
);
}
 

class Photo extends Model {
    public $name = 'Photo';
    public $belongsTo = array('Album');
}

I currently have 3 albums, one with 0 photos, one with 1 photo, and one with 2 photos.  When I do the following in the controller, I expect to get 3 albums back:

$albumlist = $this->Album->find('all');
debug($albumlist);

But in fact, I get 4 - the one with 2 photos is shown twice.  If I had another photo, I get the album back 3 times.  I'm absolutely stumped as to what's causing this, and have a feeling it must be something really stupid that I've done.  I've set up much more complex models than this in the past, with no problems.

Also, when I try to retrieve a photo, I don't get the associated album back, just the photo itself.

Can anyone see anything wrong in what I've got so far?

Thanks!

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

isAuthorized() is not working in custom controller

Hi,

My custom controller ' PostsController.php'  and inside this a have given the following code :---


    public function isAuthorized($user = null) {
        // parent::isAuthorized($user);
        if($this->action == 'add'){
            return true;
        }
        
        if(in_array($this->action,array('edit','delete'))){
            $postId = $this->request->param['pass'][0];
            if($this->Post->isOwnedBy($postId,$user['id'])){
                return true;
            }
        }
        return AuthComponent::isAuthorized($user);
    }

------------------------

And in AppController  the code is : -----------

class AppController extends Controller {
//    public $components = array('DebugKit.Toolbar');
    public $components = array(
        'Auth' => array(
            'loginRedirect' => array('controller' => 'Posts', 'action'=>'index'),
            'logoutRedirect' => array('controller' =>'pages' , 'action'=>'display','home'),
            'authorize'     => array('Controller')
         )
    );
    
    public function isAuthorized($user){
        if(isset($user['role']) && $user['role'] === 'admin'){
            return true;
        }
        return false;
    }
    
    public function beforeFilter(){
        $this->Auth->allow('index','view');
    }
    
    
}
-------------------------------

the user role is admin, and author

But when I give a post using admin user.....I can also edit with author user....which is not correct according to the coding...
that means isAuthorized is not working on PostsController
Could someone give me solution

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Monday, July 29, 2013

Re: Dealing with big cakephp applications

Hello Diogo,

So, it seems to me that you need to create a Service Oriented Architecture (SOA) in order to facilitate seamless communication for these three different 
modules (User and Permission management, Projects, and Financing) kind of like what Amazon did and I would also be looking into creating that app as 
a Multi-Tenant application. That way, you can point each main part of the app to a sub-domain, but maintain only a single copy of that application, which in 
turn sort of brings down the complexity level a bit for testing. Turning your application into a Software as a Service (SaaS) can prove to be beneficial, but on 
the flip side it may not be what you want, so be sure to research the pros and cons to see how best it fits your needs.

The next important thing that you should consider is how your storing the data, meaning if you want to go with a relational database or a No-SQL datastore. I 
assume that you are already using a relational database, so migrating to something else at this time will be tremendous work given the size of the app now. 
For example, PostgreSQL a popular opensource RDBMS allows you to store schema-less data using Hstore. You could for example, define scopes 
to limit or restrict certain data and fields based on which sub-domain your on.

Also, as Reuben suggested, try to find those parts of the current app that intersects and build them out into a plugin, so you can share them across domains 
and when you add a new feature(s) or re-factor some existing feature(s) all the apps gets updated, given that composer is what you are using to manage these 
packages; nonetheless, it shouldn't be a problem updating features.

In the end, there are many ways you could go about doing this, but I suggest that you look into SOA and Multi-Tenant applications. Here is a small case 
study on Multi-tenancy with CakePHP. I hope this helps to get you started.

On Monday, 29 July 2013 12:48:48 UTC-4, Diogo FC Patrao wrote:
Hello

In my company, we develop software with cakephp for internal usage. The software is getting big for managing it as a single project (46 controllers, 94 models), and we've been thinking about splitting it in two or three different software, each to manage one different domain of the big picture (like, a system for user and permission management, other for projects, other for financing).

However, there is the need for those modules keep comunicating. For instance, a report will need to get for all projects belonging to user X the current balance - That would need at least three models in three different modules. If I would be working with three different and independent cakephp, either I need to (1) get a copy of models from the other software, or (2) communicate via webservices.

(1) is faster, however, I'll have a huge number of models anyway. Not to mention, as business rules are in the models, when one is updated, it must be copied to the other systems, causing a maintenance nightmare.

(2) is ideal as it really encapsulate responsabilities, however it is slow. For instance, if I make a find on model Projects, each having a list of people linked to it, I'd like to bind those models. As far as I know, there's no Webservice Datasource, so I'll need to do it by hand.

I'd rather (3) have everything deployed in one big cakephp installation, but maintain my repositories apart; however it would difficult testing. But I guess that, when working with big problems like that, you really have to face some difficulties.

What are your thoughts on that problem?

Thanks!

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Re: Dealing with big cakephp applications

I might suggest usage of plugins, and perhaps composer.

I'm not sure if you're talking about physical domains, when it comes to the split (as in there's one URL for users and permissions, another for projects and another for financing).  Lets assume you do, and address the alternative later on.

So, with three domains, that's possibly 3 applications, and those applications just include the plugins that are relevant for the app to run.  Some apps may share the same plugin, so use composer to source the plugins from a single location.  There's a fair bit of refactoring in there, so you'd want to think about it very carefully.

Now, the alternative, it's still the single domain, but you just want to split the source up.  I'd still suggest plugins.  Find a handful of controllers and models that work tightly together and isolate them in their own plugin. Conceivably, you could drop that plugin to any other project and use it.  There may be a dependency tree on other plugins.  And you could still use composer to help manage including specific versions of the plugins into the single app.

I'd be excited to consider usage of namespaces to aid with the split.  It's not something that I've dived into yet with PHP, and I'll be waiting until CakePHP 3.0 before I do.

Not sure what you're using for source control, but I'd shy away from git submodules. For the few dealings that I've had with them, they seem to introduce more problems that they're worth.

My 2c on large systems with shared components.

Regards
Reuben Helms

On Tuesday, 30 July 2013 02:48:48 UTC+10, Diogo FC Patrao wrote:
Hello

In my company, we develop software with cakephp for internal usage. The software is getting big for managing it as a single project (46 controllers, 94 models), and we've been thinking about splitting it in two or three different software, each to manage one different domain of the big picture (like, a system for user and permission management, other for projects, other for financing).

However, there is the need for those modules keep comunicating. For instance, a report will need to get for all projects belonging to user X the current balance - That would need at least three models in three different modules. If I would be working with three different and independent cakephp, either I need to (1) get a copy of models from the other software, or (2) communicate via webservices.

(1) is faster, however, I'll have a huge number of models anyway. Not to mention, as business rules are in the models, when one is updated, it must be copied to the other systems, causing a maintenance nightmare.

(2) is ideal as it really encapsulate responsabilities, however it is slow. For instance, if I make a find on model Projects, each having a list of people linked to it, I'd like to bind those models. As far as I know, there's no Webservice Datasource, so I'll need to do it by hand.

I'd rather (3) have everything deployed in one big cakephp installation, but maintain my repositories apart; however it would difficult testing. But I guess that, when working with big problems like that, you really have to face some difficulties.

What are your thoughts on that problem?

Thanks!

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Dealing with big cakephp applications

Hello

In my company, we develop software with cakephp for internal usage. The software is getting big for managing it as a single project (46 controllers, 94 models), and we've been thinking about splitting it in two or three different software, each to manage one different domain of the big picture (like, a system for user and permission management, other for projects, other for financing).

However, there is the need for those modules keep comunicating. For instance, a report will need to get for all projects belonging to user X the current balance - That would need at least three models in three different modules. If I would be working with three different and independent cakephp, either I need to (1) get a copy of models from the other software, or (2) communicate via webservices.

(1) is faster, however, I'll have a huge number of models anyway. Not to mention, as business rules are in the models, when one is updated, it must be copied to the other systems, causing a maintenance nightmare.

(2) is ideal as it really encapsulate responsabilities, however it is slow. For instance, if I make a find on model Projects, each having a list of people linked to it, I'd like to bind those models. As far as I know, there's no Webservice Datasource, so I'll need to do it by hand.

I'd rather (3) have everything deployed in one big cakephp installation, but maintain my repositories apart; however it would difficult testing. But I guess that, when working with big problems like that, you really have to face some difficulties.

What are your thoughts on that problem?

Thanks!

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Model HABTM Model Referencing Original Model

This is a duplicate of my question asked on StackOverflow here: http://stackoverflow.com/questions/17875143/model-habtm-model-referencing-original-model
If you could answer the question there, or let me know if it is a bug or not, it would be greatly appreciated.

I have a Team model that is HABTM Match and when I pull the data for a specific Team, I ask for the related Teams for those Matches, but Cake only returns the data for the original Team.

How can I get all the Teams (the opponent) for that Match without looping through the results and pulling them that way?

I am having the same issue with the Team HABTM Player association as well.  When I pull a Player, Cake will not return any of the associated Players (teammates) for the linked Team.

My schema:

    CREATE TABLE IF NOT EXISTS `matches` (
      `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
      `tournament_id` int(10) unsigned NOT NULL,
      `name` varchar(255) NOT NULL DEFAULT '',
      `created` datetime NOT NULL,
      PRIMARY KEY (`id`),
      KEY `tournament_id` (`tournament_id`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 ;
    
    
    CREATE TABLE IF NOT EXISTS `matches_teams` (
      `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
      `match_id` int(10) unsigned NOT NULL,
      `team_id` int(10) unsigned NOT NULL,
      PRIMARY KEY (`id`),
      UNIQUE KEY `match_id` (`match_id`,`team_id`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 ;
    
    
    CREATE TABLE IF NOT EXISTS `players` (
      `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
      `name` varchar(255) NOT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 ;
    
    
    CREATE TABLE IF NOT EXISTS `players_teams` (
      `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
      `player_id` int(10) unsigned NOT NULL,
      `team_id` int(10) unsigned NOT NULL,
      PRIMARY KEY (`id`),
      UNIQUE KEY `player_id` (`player_id`,`team_id`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 ;
    
    
    CREATE TABLE IF NOT EXISTS `teams` (
      `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
      `tournament_id` int(10) unsigned NOT NULL,
      `name` varchar(255) NOT NULL,
      `seed` smallint(2) DEFAULT NULL,
      PRIMARY KEY (`id`),
      KEY `tournament_id` (`tournament_id`),
      KEY `seed` (`seed`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 ;

My query:
    
    $this->Team->recursive = 3;
    $team = $this->Team->read(null, $id);
    $this->set('team', $team);

I have also tried:

    $this->Team->contain(array(
        'Match' => array(
            'Team',
        ),
    ));
    $team = $this->Team->read(null, $id);
    $this->set('team', $team);

The results (`$team`):

    array (size=4)
      'Team' => 
        array (size=5)
          ... team data ...

      'Match' => 
        array (size=2)
          0 => 
            array (size=9)
              ... match data ...
              
              'MatchesTeam' => 
                array (size=3)
                  'id' => string '1' (length=1)
                  'match_id' => string '1' (length=1)
                  'team_id' => string '1' (length=1)

            // there should be an array for 'Team' here
            // that contains the opponent team

          1 => 
            ... more match data with same missing 'Team' array ...

        ... other related models ...

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.