├── .gitattributes ├── .gitignore ├── README.md ├── _config.yml ├── app.css ├── composer.json ├── delete_file.php ├── delete_image.php ├── delete_video.php ├── index.php ├── load_images.php ├── upload_file.php ├── upload_file_validation.php ├── upload_image.php ├── upload_image_resize.php ├── upload_image_validation.php └── upload_video.php /.gitattributes: -------------------------------------------------------------------------------- 1 | .travis.yml export-ignore 2 | deploy_sdk.sh export-ignore 3 | docker-compose.yml.template export-ignore 4 | Dockerfile export-ignore 5 | push-image-to-nexus.sh export-ignore 6 | version.json export-ignore -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | uploads/ 2 | composer.lock 3 | vendor/ 4 | **/.DS_STORE 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Example for using Froala WYSIWYG Editor PHP SDK 2 | 3 | Easing the [Froala WYSIWYG HTML Editor](https://github.com/froala/wysiwyg-editor) server side integration in PHP projects. 4 | 5 | ## Dependencies 6 | 7 | PHP version >= 5.4.0 is required. 8 | 9 | The following PHP extensions are required: 10 | 11 | * fileinfo 12 | * imagick 13 | 14 | ## Setup Instructions 15 | 1. Install composer within the example directory. You can find instructions on how to install composer on composer’s website (https://getcomposer.org/download/) 16 | 2. Add Froala WYSIWYG Editor PHP SDK in your compose.json file 17 | 18 | { 19 | "require" : { 20 | "froala/wysiwyg-editor-php-sdk" : "" 21 | } 22 | } 23 | 3. Run composer: 24 | 25 | php composer.phar install 26 | 27 | Or if you installed composer globally: 28 | 29 | composer install 30 | 4. Before running the application, create 'uploads' folder at wamp www root directory 31 | 32 | ## Documentation 33 | 34 | * [Official documentation](https://www.froala.com/wysiwyg-editor/docs/sdks/php) 35 | 36 | ## Help 37 | - Found a bug or have some suggestions? Just submit an issue. 38 | - Having trouble with your integration? [Contact Froala Support team](http://froala.dev/wysiwyg-editor/contact). 39 | 40 | ## License 41 | 42 | The Froala WYSIWYG Editor PHP SDK is licensed under MIT license. However, in order to use Froala WYSIWYG HTML Editor plugin you should purchase a license for it. 43 | 44 | Froala Editor has [3 different licenses](http://froala.com/wysiwyg-editor/pricing) for commercial use. 45 | For details please see [License Agreement](http://froala.com/wysiwyg-editor/terms). 46 | 47 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-minimal -------------------------------------------------------------------------------- /app.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding: 20px; 3 | } 4 | 5 | .sample { 6 | padding-bottom: 50px; 7 | margin-left: 30px; 8 | border-top: 1px solid lightgray; 9 | } 10 | 11 | .manual { 12 | margin-bottom: 20px; 13 | } -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "froala/wysiwyg-editor-php-sdk-example", 3 | "require": { 4 | "components/jquery": ">=1.11.0", 5 | "fortawesome/font-awesome": ">=4.4.0", 6 | "froala/wysiwyg-editor": ">=4.5.2", 7 | "froala/wysiwyg-editor-php-sdk": "4.5.2" 8 | }, 9 | "support": { 10 | "issues": "https://github.com/froala/froala-editor-php-sdk/issues", 11 | "source": "https://www.froala.com/wysiwyg-editor" 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /delete_file.php: -------------------------------------------------------------------------------- 1 | getMessage(); 17 | http_response_code(404); 18 | } -------------------------------------------------------------------------------- /delete_image.php: -------------------------------------------------------------------------------- 1 | getMessage(); 18 | http_response_code(404); 19 | } -------------------------------------------------------------------------------- /delete_video.php: -------------------------------------------------------------------------------- 1 | getMessage(); 18 | http_response_code(404); 19 | } -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | 'Europe/Bucharest', 22 | 'bucket' => $bucket, 23 | 'region' => $region, 24 | 'keyStart' => $keyStart, 25 | 'acl' => $acl, 26 | 'accessKey' => $accessKeyId, 27 | 'secretKey' => $secretKey 28 | ); 29 | 30 | $hash = FroalaEditor_S3::getHash($config); 31 | $hash = stripslashes(json_encode($hash)); 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 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 |
100 |

Sample 1: Save to disk

101 |
102 | 103 |
104 |
105 | 208 | 209 |
210 |

Sample 2: Save to disk (resize on server)

211 |
212 | 213 |
214 |
215 | 289 | 290 |
291 |

Sample 3: Save to disk with custom validation: Images must be squares (width == height). Files must not exceed 10M.

292 |
293 | 294 |
295 |
296 | 373 | 374 |
375 |

Sample 4: Save to Amazon using signature version 4

376 |
377 | 378 |
379 |
380 | 381 | 391 | 392 | 393 | 394 | -------------------------------------------------------------------------------- /load_images.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /upload_file.php: -------------------------------------------------------------------------------- 1 | null 7 | ); 8 | 9 | try { 10 | $response = FroalaEditor_File::upload('/uploads/', $options); 11 | echo stripslashes(json_encode($response)); 12 | } catch (Exception $e) { 13 | echo $e->getMessage(); 14 | http_response_code(404); 15 | } -------------------------------------------------------------------------------- /upload_file_validation.php: -------------------------------------------------------------------------------- 1 | 'myFile', 7 | 'validation' => function($filePath, $mimetype) { 8 | 9 | $size = filesize($filePath); 10 | 11 | if ($size > 10 * 1024 * 1024) { 12 | return false; 13 | } 14 | 15 | return true; 16 | } 17 | ); 18 | 19 | try { 20 | $response = FroalaEditor_File::upload('/uploads/', $options); 21 | echo stripslashes(json_encode($response)); 22 | } catch (Exception $e) { 23 | echo $e->getMessage(); 24 | http_response_code(404); 25 | } -------------------------------------------------------------------------------- /upload_image.php: -------------------------------------------------------------------------------- 1 | getMessage(); 12 | http_response_code(404); 13 | } -------------------------------------------------------------------------------- /upload_image_resize.php: -------------------------------------------------------------------------------- 1 | array( 7 | 'columns' => 300, 8 | 'rows' => 300, 9 | 'bestfit' => true 10 | ) 11 | ); 12 | 13 | try { 14 | $response = FroalaEditor_Image::upload('/uploads/', $options); 15 | echo stripslashes(json_encode($response)); 16 | } catch (Exception $e) { 17 | echo $e->getMessage(); 18 | http_response_code(404); 19 | } -------------------------------------------------------------------------------- /upload_image_validation.php: -------------------------------------------------------------------------------- 1 | 'myImage', 7 | 'validation' => function($filePath, $mimetype) { 8 | 9 | $imagick = new \Imagick($filePath); 10 | $size = $imagick->getImageGeometry(); 11 | $imagick->destroy(); 12 | 13 | if ($size['width'] != $size['height']) { 14 | return false; 15 | } 16 | 17 | return true; 18 | } 19 | ); 20 | 21 | try { 22 | $response = FroalaEditor_Image::upload('/uploads/', $options); 23 | echo stripslashes(json_encode($response)); 24 | } catch (Exception $e) { 25 | echo $e->getMessage(); 26 | http_response_code(404); 27 | } -------------------------------------------------------------------------------- /upload_video.php: -------------------------------------------------------------------------------- 1 | getMessage(); 11 | http_response_code(404); 12 | } 13 | --------------------------------------------------------------------------------