Many thanks to the CakePHP mailing list for pointing out some really dumb errors I made along the way getting this stuff to work. It turns out that case-sensitivity does actually matter at time. :)
Okay, for a project at work I was asked to add graphs to some of the reports I’d already created. So I looked around for solutions for graphing in PHP and stumbled upon PHP/SWF Charts as a solution. Basically, it comes in two parts: a Flash movie that generates the charts for you and a PHP library that sends data to the Flash movie to create those great charts.
So, first thing I did was download the package from the PHP/SWF Charts site. I then dumped everything into a /graphs directory in my web root. Why? Well, that’s the only way I could get the thing working and I am a disciple who worships at the altar of Get It Done because there are other things I’d rather deal with. I’m sure one of the CakePHP people who runs across this tutorial can correct things for me so it’s all inside the framework itself.
Now, that the library is unzipped and in it’s own directory, we go and start altering the code I need to make this work. First thing I did was add a subdirectory to my app/views directory called graphs and added in users.thtml
1
2
3
4
5
6
7
8
9
1
2
3
4
5
6
7
Okay, so now here’s the code I created to pull results from our database, munge the data and pass it over to the view:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
So, I think that’s all you need in order to get your code working and talking nicely with PHP/SWF charts. I’ll go over this stuff again to look for any errors and clear up anything that looks confusing.