|
1 |
| -# Laravel chunked upload example |
| 1 | +# Laravel Chunked Upload Example |
2 | 2 |
|
3 |
| -> This example covers all supported Laravel versions. This implementation will allow us to test all versions at once. |
| 3 | +> This example covers all supported versions of Laravel. This implementation allows testing across all versions simultaneously. |
4 | 4 |
|
5 |
| -This repo contains full example for [laravel-chunk-upload](https://github.com/pionl/laravel-chunk-upload) package. |
| 5 | +This repository contains a full example for the [laravel-chunk-upload](https://github.com/pionl/laravel-chunk-upload) package. You can either explore an example app or run tests against all supported versions of Laravel. |
6 | 6 |
|
7 | 7 | * [Usage](#usage)
|
8 | 8 | * [Compatibility](#compatibility)
|
9 |
| -* [Run tests](#tests) |
10 |
| -* [Example code](#example-code) |
11 |
| -* [Testing your contribution](#testing-your-contribution) |
12 |
| -* [Adding new Laravel release](#adding-a-support-for-new-laravel-release) |
| 9 | +* [Running Tests](#tests) |
| 10 | +* [Example Code](#example-code) |
| 11 | +* [Testing Your Contribution](#testing-your-contribution) |
| 12 | +* [Contribution](#contribution) |
13 | 13 |
|
14 | 14 | ## Install
|
15 | 15 |
|
| 16 | +```bash |
| 17 | +git clone git@github.com:pionl/laravel-chunk-upload-example.git --recurse-submodules |
| 18 | +npm install |
16 | 19 | ```
|
17 |
| -git clone git@github.com:pionl/laravel-chunk-upload-example.git --recurse-submodules --remote-submodules |
18 |
| -npm install --only=production |
19 |
| -``` |
| 20 | + |
| 21 | +## Requirements |
| 22 | + |
| 23 | +- PHP Installed if running locally |
| 24 | +- Node.js |
| 25 | +- Docker and Docker Compose installed |
20 | 26 |
|
21 | 27 | ## Usage
|
22 | 28 |
|
23 |
| -**Install and run specific Laravel version. Use X.\* version format.** |
| 29 | +**To install and run a specific version of Laravel, use the X.\* version format.** |
24 | 30 |
|
25 |
| -``` |
| 31 | +```bash |
26 | 32 | node run.js "8.*"
|
27 | 33 | ```
|
28 | 34 |
|
29 |
| -> Pass --ignore-example to ignore updating and building example |
30 |
| -> Pass --verbose for debug info |
31 |
| -
|
| 35 | +> Pass _--ignore-example_ to ignore updating and building the example. |
| 36 | +> |
| 37 | +> Pass _--verbose_ for debug information. |
32 | 38 |
|
33 |
| -open http://localhost:8000 |
| 39 | +Open http://localhost:8000 |
34 | 40 |
|
35 |
| -## Compatibility |
| 41 | +## Compatibility |
36 | 42 |
|
37 |
| -> Current version of laravel-chunk-upload is tested against: |
| 43 | +> The current version of laravel-chunk-upload is tested against: |
38 | 44 |
|
39 | 45 | | Laravel | PHP | Run | Tests |
|
40 | 46 | |---------|---------------------------------------|-------------------|------------------------|
|
| 47 | +| 10.* | 8.2-node-20, 8.2-node-20 | `node run "11.*"` | `node tests.js "11.*"` | |
41 | 48 | | 10.* | 8.1-node-17, 8.2-node-18 | `node run "10.*"` | `node tests.js "10.*"` |
|
42 | 49 | | 9.* | 8.0-node-17, 8.1-node-17, 8.2-node-18 | `node run "9.*"` | `node tests.js "9.*"` |
|
43 | 50 | | 8.* | 7.4-node-17, 8.0-node-17, 8.1-node-17 | `node run "8.*"` | `node tests.js "8.*"` |
|
44 | 51 | | 7.* | 7.4-node-17 | `node run "7.*"` | `node tests.js "7.*"` |
|
45 | 52 |
|
46 | 53 | ## Tests
|
47 | 54 |
|
48 |
| -> Pass --verbose for debug info |
| 55 | +> Pass --verbose for debug information. |
49 | 56 |
|
50 |
| -**Run tests on all Laravel versions (install them before using it)** |
| 57 | +**Run tests on all Laravel versions (install them before using it) using docker** |
51 | 58 |
|
52 |
| -``` |
| 59 | +```bash |
53 | 60 | node tests.js
|
54 | 61 | ```
|
55 | 62 |
|
56 |
| -**Run tests on desired Laravel version** |
| 63 | +**Run tests on a desired Laravel version** |
57 | 64 |
|
58 |
| -``` |
| 65 | +```bash |
59 | 66 | node tests.js "8.*"
|
60 | 67 | ```
|
61 | 68 |
|
62 |
| -### Tests locally |
| 69 | +### Running Tests Locally |
63 | 70 |
|
64 |
| -> Run `npm install` without production. |
| 71 | +* In one terminal, run `php 7.\*/artisan serve --host=0.0.0.0 --port=8000`. |
| 72 | +* In a second terminal, run tests with `./node_modules/.bin/codeceptjs run --steps`. |
| 73 | +* `npm run test-debug` will show the browser while tests are running. |
65 | 74 |
|
66 |
| -* In one terminal run `php 7.\*/artisan serve --host=0.0.0.0 --port=8000` |
67 |
| -* In second terminal run tests `./node_modules/.bin/codeceptjs run --steps` |
68 |
| -* `npm run test-debug` will show browser while tests are running. |
| 75 | +### Docker-Compose |
69 | 76 |
|
70 |
| -### Docker-compose |
71 |
| - |
72 |
| -* Environment variables should be passed: `IMAGE_VERSION` (php version) and `LARAVEL_VERSION`. |
73 |
| -* `abort-on-container-exit` needs to be used to stop Laravel server. |
| 77 | +* Environment variables should be passed: `IMAGE_VERSION` (PHP version) and `LARAVEL_VERSION`. |
| 78 | +* `abort-on-container-exit` needs to be used to stop the Laravel server. |
74 | 79 |
|
75 | 80 | ```bash
|
76 | 81 | IMAGE_VERSION=7.4 LARAVEL_VERSION=8.\* docker-compose -f docker-compose.yml -f docker-compose-tests.yml up --abort-on-container-exit
|
77 | 82 | ```
|
78 | 83 |
|
79 |
| -## Running tests on latest Laravel release |
| 84 | +## Testing Your Contribution |
80 | 85 |
|
81 |
| -**I did not find a way how to install Laravel on master with the latest changes from framework -- let me know if you know how** |
| 86 | +> Do not commit your changes - use a pull request in the main repo. |
82 | 87 |
|
83 |
| -## Testing your contribution |
| 88 | +* Replace the `laravel-chunk-upload` folder with your repository (clone your fork). |
| 89 | +* Or you can pull changes from your fork with with given bash script: |
84 | 90 |
|
85 |
| -> Do not commit your changes - use pull request in main repo |
| 91 | +```bash |
| 92 | +pr.sh <your-github-username> <branch = default is master> <repository-name = laravel-chunk-upload> |
| 93 | +``` |
| 94 | +* Run tests on all versions with `node tests.js` to ensure backward compatibility. |
86 | 95 |
|
87 |
| -* Replace `laravel-chunk-upload` folder with your repository (clone your fork) |
88 |
| -* Maintainer can pull PR |
89 |
| - |
90 |
| - ```bash |
91 |
| - cd laravel-chunk-upload |
92 |
| - git checkout -b drjdr-master master |
93 |
| - git pull https://github.com/drjdr/laravel-chunk-upload.git master |
94 |
| - cd .. |
95 |
| - ``` |
96 |
| -* Run tests on all versions `node tests.js` to ensure backward compatibility. |
| 96 | +## Adding Support for a New Laravel Release |
97 | 97 |
|
98 |
| -## Adding a support for new Laravel release |
| 98 | +- Docker and Docker Compose installed. |
| 99 | +- Node.js installed. |
99 | 100 |
|
100 |
| -- Docker + docker compose installed |
101 |
| -- Node.js installed |
| 101 | +> Do not commit your changes - use a pull request in the main repo. |
102 | 102 |
|
103 |
| -> Do not commit your changes - use pull request in main repo |
| 103 | +* Add a new version to the `versions.json` file. |
| 104 | +* Add your changes to the `laravel-chunk-upload` folder. |
| 105 | +* Test the Laravel version with `node tests.js "10.\*"`. |
| 106 | +* Run tests on all versions with `node tests.js` to ensure backward compatibility. |
104 | 107 |
|
105 |
| -* Add a new version to `versions.json` file. |
106 |
| -* Add your changes to `laravel-chunk-upload` folder |
107 |
| -* Test the Laravel version `node tests.js "10.\*"` |
108 |
| -* Run tests on all versions `node tests.js` to ensure backward compatibility. |
| 108 | +## Example Code |
109 | 109 |
|
110 |
| -## Example code |
| 110 | +* **Controller - Dynamic Usage** at [./example/src/Http/Controllers/UploadController.php](./example/src/Http/Controllers/UploadController.php) |
| 111 | +* **Views** at [./example/resources/views/example/](./example/resources/views/example/) - Here, you can find a basic layout for the providers. |
| 112 | +* **JavaScript** at [./example/resources/assets/js/](./example/resources/assets/js/) - Here, you can find the initial setup for the providers. |
111 | 113 |
|
112 |
| -* **Controller - dynamic usage** at [./example/src/Http/Controllers/UploadController.php](./example/src/Http/Controllers/UploadController.php) |
113 |
| -* **Views** at [./example/resources/views/example/](./example/resources/views/example/) - Here you can find basic layout for the providers. |
114 |
| -* **Javascripts** at [./example/resources/assets/js/](./example/resources/assets/js/) - Here you can find the initial setup for the providers. |
| 114 | +### Uploading to Amazon S3 (or Any Other Cloud Storage) |
115 | 115 |
|
116 |
| -### Uploading to AMAZON s3 (or any other cloud storage) |
| 116 | +* It is recommended to upload the file in a separate queue JOB. Uploading can take time (for large files), and the request could get timed out. |
| 117 | +* It is important to stream the file to the cloud (not using `file_get_contents`), which would consume your memory. |
| 118 | +* Also, don't forget to remove the uploaded file after the upload. |
117 | 119 |
|
118 |
| -* It is recommended to upload the file in separate queue JOB. Uploading can take a time (for large files) and the request could |
119 |
| -get timed out. |
120 |
| -* It is important to stream the file to the cloud (not using `file_get_contents`) which would eat your memory. |
121 |
| -* Also don't forget to remove the uploaded file after the upload. |
| 120 | +Example code found at [./example/src/Http/Controllers/UploadController.php](./example/src/Http/Controllers/UploadController.php#L59). |
122 | 121 |
|
123 |
| -Example code found at [./example/sr/Http/Controllers/UploadController.php](./example/src/Http/Controllers/UploadController.php#L59). |
124 | 122 |
|
125 |
| -## Contribution in example |
| 123 | +## Contribution |
126 | 124 |
|
127 |
| -* If you make changes in assets, do not forget to call `node compile.js` to compile the changes and publish them to all version (you can also pass desired version) |
| 125 | +* If you make changes in assets, do not forget to call `node compile.js` to compile the changes and publish them to all versions (you can also pass the desired version). |
128 | 126 |
|
129 | 127 | # TODO
|
130 | 128 |
|
131 |
| -- Improve example controller |
132 |
| -- Add tests to dropzone |
133 |
| -- clean storage after tests |
134 |
| -- Add tests for paraller save |
| 129 | +- Improve example controller. |
| 130 | +- Add tests to Dropzone. |
| 131 | +- Clean storage after tests. |
| 132 | +- Add tests for parallel save. |
| 133 | + |
| 134 | +### Running Tests on the Latest Laravel Release |
| 135 | + |
| 136 | +**I did not find a way to install Laravel on master with the latest changes from the framework. Let me know if you know how.** |
| 137 | + |
135 | 138 |
|
136 | 139 | ## Copyright and License
|
137 | 140 |
|
138 | 141 | [laravel-chunk-upload-example](https://github.com/pionl/laravel-chunk-upload-example)
|
139 |
| -was written by [Martin Kluska](http://kluska.cz) and is released under the |
| 142 | +was written by [Martin Kluska](http://kluska.cz) and is released under the |
140 | 143 | [MIT License](LICENSE.md).
|
141 | 144 |
|
142 |
| -Copyright (c) 2017 and beyond Martin Kluska |
| 145 | +Copyright (c) 2017 and beyond Martin Kluska and all the contributors (Thank you ❤️) |
0 commit comments