DeepskyLog / laravel-astronomy-library

A library to perform astronomical calculations in php / laravel
GNU General Public License v3.0
12 stars 3 forks source link

What is carbondate? #48

Closed entezarlifedesign closed 3 years ago

entezarlifedesign commented 3 years ago

I use Carbon::now() for this line:

$carbonDate = Carbon::now();
$coords = new GeographicalCoordinates(-70.73330, -29.25);
$astrolib = new AstronomyLibrary($carbonDate, $coords);

but give error:

Argument 1 passed to Symfony\Component\HttpFoundation\Response::setContent() must be of the type string or null, object given, called in D:\xampp\htdocs\rtl\vendor\laravel\framework\src\Illuminate\Http\Response.php on line 65

WimDeMeester commented 3 years ago

Hi @entezarlifedesign

This is a strange error message... At first sight, it does not look like an error in the laravel-astronomy-library, but somewhere else... The following simple example does work for me:

use Carbon\Carbon;
use deepskylog\AstronomyLibrary\Coordinates\GeographicalCoordinates;
use deepskylog\AstronomyLibrary\AstronomyLibrary;

$carbonDate = Carbon::now();
$coords = new GeographicalCoordinates(-70.73330, -29.25);
$astrolib = new AstronomyLibrary($carbonDate, $coords);

I tried to execute this example in

php artisan tinker

Can you also send me the result when running the example in tinker?

WimDeMeester commented 3 years ago

I will anyway update the documentation to include the use-statement and an example of $carbonDate

entezarlifedesign commented 3 years ago

Hello

I once again installed a new version of Laravel. I installed your package. And run the code again, but it gives the same error.

Anyway, thank you.

Which package did you use yourself?

WimDeMeester commented 3 years ago

Did you also add Carbon using

composer require nesbot/carbon

Anyway, I'll try to create a new laravel project and try to reproduce your error.

WimDeMeester commented 3 years ago

I did the following

laravel new test
cd test
composer require deepskylog/laravel-astronomy-library

I do php artisan tinker then, and I execute the small script:

use Carbon\Carbon;
use deepskylog\AstronomyLibrary\Coordinates\GeographicalCoordinates;
use deepskylog\AstronomyLibrary\AstronomyLibrary;

$carbonDate = Carbon::now();
$coords = new GeographicalCoordinates(-70.73330, -29.25);
$astrolib = new AstronomyLibrary($carbonDate, $coords);

I don't see any errors.

Can you tell me which version of php and laravel you have (and which operating system?)

entezarlifedesign commented 3 years ago

I did the following

laravel new test
cd test
composer require deepskylog/laravel-astronomy-library

I do php artisan tinker then, and I execute the small script:

use Carbon\Carbon;
use deepskylog\AstronomyLibrary\Coordinates\GeographicalCoordinates;
use deepskylog\AstronomyLibrary\AstronomyLibrary;

$carbonDate = Carbon::now();
$coords = new GeographicalCoordinates(-70.73330, -29.25);
$astrolib = new AstronomyLibrary($carbonDate, $coords);

I don't see any errors.

Can you tell me which version of php and laravel you have (and which operating system?)

Reinstall carbon, But it still does not work.

windows 10, latest update laravel 8 and 7 tested php 7.3 in xampp 3.2.4 64bit

composer updated node updated

WimDeMeester commented 3 years ago

The problem is that this package needs php 7.4. It is stated in the composer.json file, so I don't understand why the package can be installed at all.

entezarlifedesign commented 3 years ago

The problem is that this package needs php 7.4. It is stated in the composer.json file, so I don't understand why the package can be installed at all.

OMG! I installed directly from laravel command line and i didn't pay attention to the composer.json file! Please add recommended/Requirements section top of the page! This is customary!

However, I installed version 7.4 but it still did not work

Thank you.

WimDeMeester commented 3 years ago

I was under the impression that the composer.json file would force composer install to check the php version. I'll adapt the documentation.

WimDeMeester commented 3 years ago

Can I ask you @entezarlifedesign why you would want to use laravel-astronomy-library?