Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/luisprmat/useful-tricks
Some programming tricks for develop apps
https://github.com/luisprmat/useful-tricks
Last synced: about 2 hours ago
JSON representation
Some programming tricks for develop apps
- Host: GitHub
- URL: https://github.com/luisprmat/useful-tricks
- Owner: luisprmat
- License: mit
- Created: 2022-08-11T00:11:26.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-08-11T00:45:35.000Z (over 2 years ago)
- Last Synced: 2024-11-11T18:45:00.867Z (about 2 months ago)
- Size: 1.95 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Useful Tricks
Some programming tricks for develop apps.
## FakerPHP doesn't work!
Sometimes [FakerPHP](https://fakerphp.github.io/formatters/image) doesn't generate images properly. In this case I use a dirty trick (from a [Laravel](https://github.com/laravel/laravel) App):
- Search in the file [`vendor/fakerphp/src/Faker/Provider/Image.php`](https://github.com/FakerPHP/Faker/blob/main/src/Faker/Provider/Image.php) the line with the variable `BASE_URL` and change its value by `https://placehold.jp````diff
class Image extends Base
{
/**
* @var string
*/
- public const BASE_URL = 'https://via.placeholder.com';
+ public const BASE_URL = 'https://placehold.jp';public const FORMAT_JPG = 'jpg';
public const FORMAT_JPEG = 'jpeg';
public const FORMAT_PNG = 'png';
// ...
}
```- In the same file search the line `curl_setopt($ch, CURLOPT_FILE, $fp);` (approx line [144](https://github.com/FakerPHP/Faker/blob/main/src/Faker/Provider/Image.php#L144)) inside the static method `image` and *add* two new lines as in the code fragment.
```diff
class Image extends Base
{
// ...
public static function image(
// parameters
) {
// ...
// save file
if (function_exists('curl_exec')) {
// use cURL
$fp = fopen($filepath, 'w');
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_FILE, $fp);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$success = curl_exec($ch) && curl_getinfo($ch, CURLINFO_HTTP_CODE) === 200;
// ...
}
// ...
}
// ...
}
```
- Ready!