With CakePHP it is quite easy to send any string as a subfile. As an example below is the creation of an ICS subfile (for a calendar invites)
1public function sendIcs()
2{
3 $icsString = $this->Calendars->generateIcs();
4 $response = $this->response;
5
6 // Inject string content into response body
7 $response = $response->withStringBody($icsString);
8
9 $response = $response->withType('ics');
10
11 // Optionally force file download
12 $response = $response->withDownload('filename_for_download.ics');
13
14 // Return response object to prevent controller from trying to render
15 // a view.
16 return $response;
17}
Example above is from official CakePHP book.