Last active
January 15, 2022 08:34
-
-
Save MayMeow/c2ff4cc882d0a7923d1546b0092e30b1 to your computer and use it in GitHub Desktop.
Cakephp Send string as file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function sendIcs() | |
{ | |
$icsString = $this->Calendars->generateIcs(); | |
$response = $this->response; | |
// Inject string content into response body | |
$response = $response->withStringBody($icsString); | |
$response = $response->withType('ics'); | |
// Optionally force file download | |
$response = $response->withDownload('filename_for_download.ics'); | |
// Return response object to prevent controller from trying to render | |
// a view. | |
return $response; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment