Comments (9)
Indeed, I don't know why. But since there is a much better way to do, let's close this for now.
Thanks for the issue!
from castor.
I have implemented a workaround at PHP level but it is not ideal
file_get_contents('https://[...]', context: stream_context_create([
"ssl" => [
"verify_peer" => false,
"verify_peer_name" => false,
],
]));
from castor.
Is the URL Public so we can test? Or does it work with GitHub.com for example?
If you have SSL error you can also use the http client with some options to disable peer verification
from castor.
Yes
#[AsTask(description: 'https://github.com/jolicode/castor/issues/430')]
function issue430()
{
file_get_contents('https://github.com/jolicode/castor/blob/main/composer.json');
}
it works with Castor but it doesn't work with binary
Maybe it's a cacert.pem problem but it's not present in Castor either and it works
from castor.
Hello, I tried the following setup
- download a static binary: https://castor.jolicode.com/getting-started/installation/#as-a-static-binary
- Create a new castor.php with the following content:
<?php use Castor\Attribute\AsTask; use function Castor\io; use function Castor\request; #[AsTask(description: 'Make HTTP request')] function httpRequest(string $url = 'https://example.com'): void { $response = request('GET', $url); io()->writeln($response->getContent()); }
- Execute it:
$ ./castor-static http | head <!doctype html> <html> <head> <title>Example Domain</title> <meta charset="utf-8" /> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <style type="text/css"> body {
$ ./castor-static http --url "https://github.com" | head <!DOCTYPE html> <html lang="en"
- ensure I got the static binary
$ file ./castor-static ./castor-static: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, stripped
Everything works as expected. what did I miss?
from castor.
For the record, I also repack + compile my app, end it still work
$ /tmp/foobar/castor-ssl/my-app.linux.x86_64 http
<!doctype html>
<html>
<head>
<title>Example Domain</title>
<meta charset="utf-8" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style type="text/css">
body {
background-color: #f0f0f2;
margin: 0;
padding: 0;
...
from castor.
And I even try in an alpine container:
$ docker run -it -v $(pwd):/app --rm alpine /app/my-app.linux.x86_64 http
<!doctype html>
<html>
<head>
<title>Example Domain</title>
<meta charset="utf-8" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style type="text/css">
body {
background-color: #f0f0f2;
margin: 0;
padding: 0;
font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
}
from castor.
Thanks a lot !
There is no problem with request()
// βοΈ OK
$response = request('GET', 'https://github.com/jolicode/castor/blob/main/composer.json');
$json = $response->getContent();
But there is a problem with file_get_contents()
// π« WARNING
$json = file_get_contents('https://github.com/jolicode/castor/blob/main/composer.json');
I'm going to use request() for now but there is a problem with certificates if we directly use a native PHP function.
from castor.
This thread documents this issue π
from castor.
Related Issues (20)
- Remote packages must be repacked too
- Problem with `vsc` import and Github API Limit HOT 1
- Specifying path for box executable in RepackCommand HOT 4
- Make `BeforeBootEvent` non-internal ? HOT 4
- Using .env files with phar file HOT 4
- `notify` context is not super clear about expected behavior HOT 1
- How can I change the terminal working directory ? HOT 5
- `fingerprint` unexpected behavior when file has changed after the command run HOT 5
- [dev-main] Error : Castor\Console\Command\TaskCommand::__construct(): Argument #2 ($expressionLanguage) must be of type Castor\ExpressionLanguage HOT 10
- Variadic argument or array HOT 2
- Broken `--install-dir` option HOT 5
- Allow an extension / plugin to register variables into context HOT 3
- `castor composer init` bad defaults
- Completion command does not work when an update is available HOT 1
- Bad βvendorβ folder embedded in .phar throws an error "Class not found" HOT 6
- Error on compiling application into a static binary HOT 2
- Run remote task HOT 1
- Async process progress indicator HOT 2
- Questions about maybe some improvements ? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from castor.