Skip to content

Commit daa000f

Browse files
authored
Merge pull request #65 from programmatordev/3.x
v3.0.0
2 parents d74c981 + f7f10b4 commit daa000f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+630
-372
lines changed

.ddev/config.yaml

Lines changed: 41 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,31 @@ disable_upload_dirs_warning: true
2020

2121
# name: <projectname> # Name of the project, automatically provides
2222
# http://projectname.ddev.site and https://projectname.ddev.site
23+
# If the name is omitted, the project will take the name of the enclosing directory,
24+
# which is useful if you want to have a copy of the project side by side with this one.
2325

24-
# type: <projecttype> # backdrop, craftcms, django4, drupal, drupal6, drupal7, laravel, magento, magento2, php, python, shopware6, silverstripe, typo3, wordpress
25-
# See https://ddev.readthedocs.io/en/stable/users/quickstart/ for more
26+
# type: <projecttype> # backdrop, cakephp, craftcms, drupal, drupal6, drupal7, drupal8, drupal9, drupal10, drupal11, generic, laravel, magento, magento2, php, shopware6, silverstripe, symfony, typo3, wordpress
27+
# See https://docs.ddev.com/en/stable/users/quickstart/ for more
2628
# information on the different project types
27-
# "drupal" covers recent Drupal 8+
2829

2930
# docroot: <relative_path> # Relative path to the directory containing index.php.
3031

31-
# php_version: "8.2" # PHP version to use, "5.6", "7.0", "7.1", "7.2", "7.3", "7.4", "8.0", "8.1", "8.2", "8.3"
32+
# php_version: "8.3" # PHP version to use, "5.6" through "8.4"
3233

3334
# You can explicitly specify the webimage but this
3435
# is not recommended, as the images are often closely tied to DDEV's' behavior,
3536
# so this can break upgrades.
3637

37-
# webimage: <docker_image> # nginx/php docker image.
38+
# webimage: <docker_image>
39+
# It’s unusual to change this option, and we don’t recommend it without Docker experience and a good reason.
40+
# Typically, this means additions to the existing web image using a .ddev/web-build/Dockerfile.*
3841

3942
# database:
4043
# type: <dbtype> # mysql, mariadb, postgres
4144
# version: <version> # database version, like "10.11" or "8.0"
42-
# MariaDB versions can be 5.5-10.8 and 10.11, MySQL versions can be 5.5-8.0
43-
# PostgreSQL versions can be 9-16.
45+
# MariaDB versions can be 5.5-10.8, 10.11, 11.4, 11.8
46+
# MySQL versions can be 5.5-8.0, 8.4
47+
# PostgreSQL versions can be 9-17
4448

4549
# router_http_port: <port> # Port to be used for http (defaults to global configuration, usually 80)
4650
# router_https_port: <port> # Port for https (defaults to global configuration, usually 443)
@@ -50,14 +54,25 @@ disable_upload_dirs_warning: true
5054
# "ddev xdebug" to enable Xdebug and "ddev xdebug off" to disable it work better,
5155
# as leaving Xdebug enabled all the time is a big performance hit.
5256

53-
# xhprof_enabled: false # Set to true to enable Xhprof and "ddev start" or "ddev restart"
54-
# Note that for most people the commands
55-
# "ddev xhprof" to enable Xhprof and "ddev xhprof off" to disable it work better,
56-
# as leaving Xhprof enabled all the time is a big performance hit.
57+
# xhgui_http_port: "8143"
58+
# xhgui_https_port: "8142"
59+
# The XHGui ports can be changed from the default 8143 and 8142
60+
# Very rarely used
61+
62+
# host_xhgui_port: "8142"
63+
# Can be used to change the host binding port of the XHGui
64+
# application. Rarely used; only when port conflict and
65+
# bind_all_ports is used (normally with router disabled)
66+
67+
# xhprof_mode: [prepend|xhgui|global]
68+
# Set to "xhgui" to enable XHGui features
69+
# "xhgui" will become default in a future major release
5770

58-
# webserver_type: nginx-fpm, apache-fpm, or nginx-gunicorn
71+
# webserver_type: nginx-fpm, apache-fpm, generic
5972

6073
# timezone: Europe/Berlin
74+
# If timezone is unset, DDEV will attempt to derive it from the host system timezone
75+
# using the $TZ environment variable or the /etc/localtime symlink.
6176
# This is the timezone used in the containers and by PHP;
6277
# it can be set to any valid timezone,
6378
# see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
@@ -77,16 +92,14 @@ disable_upload_dirs_warning: true
7792
# - preview
7893
# - snapshot
7994
# Alternatively, an explicit Composer version may be specified, for example "2.2.18".
80-
# To reinstall Composer after the image was built, run "ddev debug refresh".
95+
# To reinstall Composer after the image was built, run "ddev debug rebuild".
8196

82-
# nodejs_version: "20"
97+
# nodejs_version: "22"
8398
# change from the default system Node.js version to any other version.
84-
# Numeric version numbers can be complete (i.e. 18.15.0) or
85-
# incomplete (18, 17.2, 16). 'lts' and 'latest' can be used as well along with
86-
# other named releases.
87-
# see https://www.npmjs.com/package/n#specifying-nodejs-versions
88-
# Note that you can continue using 'ddev nvm' or nvm inside the web container
89-
# to change the project's installed node version if you need to.
99+
# See https://docs.ddev.com/en/stable/users/configuration/config/#nodejs_version for more information
100+
# and https://www.npmjs.com/package/n#specifying-nodejs-versions for the full documentation,
101+
# Note that using of 'ddev nvm' is discouraged because "nodejs_version" is much easier to use,
102+
# can specify any version, and is more robust than using 'nvm'.
90103

91104
# corepack_enable: false
92105
# Change to 'true' to 'corepack enable' and gain access to latest versions of yarn/pnpm
@@ -119,7 +132,7 @@ disable_upload_dirs_warning: true
119132

120133
# ddev_version_constraint: ""
121134
# Example:
122-
# ddev_version_constraint: ">= 1.22.4"
135+
# ddev_version_constraint: ">= 1.24.8"
123136
# This will enforce that the running ddev version is within this constraint.
124137
# See https://github.com/Masterminds/semver#checking-version-constraints for
125138
# supported constraint formats
@@ -148,8 +161,8 @@ disable_upload_dirs_warning: true
148161
# - "mutagen": enables Mutagen for this project.
149162
# - "nfs": enables NFS for this project.
150163
#
151-
# See https://ddev.readthedocs.io/en/stable/users/install/performance/#nfs
152-
# See https://ddev.readthedocs.io/en/stable/users/install/performance/#mutagen
164+
# See https://docs.ddev.com/en/stable/users/install/performance/#nfs
165+
# See https://docs.ddev.com/en/stable/users/install/performance/#mutagen
153166

154167
# fail_on_hook_fail: False
155168
# Decide whether 'ddev start' should be interrupted by a failing hook
@@ -198,17 +211,17 @@ disable_upload_dirs_warning: true
198211

199212
# ngrok_args: --basic-auth username:pass1234
200213
# Provide extra flags to the "ngrok http" command, see
201-
# https://ngrok.com/docs/ngrok-agent/config or run "ngrok http -h"
214+
# https://ngrok.com/docs/agent/config/v3/#agent-configuration or run "ngrok http -h"
202215

203216
# disable_settings_management: false
204217
# If true, DDEV will not create CMS-specific settings files like
205-
# Drupal's settings.php/settings.ddev.php or TYPO3's AdditionalConfiguration.php
218+
# Drupal's settings.php/settings.ddev.php or TYPO3's additional.php
206219
# In this case the user must provide all such settings.
207220

208221
# You can inject environment variables into the web container with:
209222
# web_environment:
210-
# - SOMEENV=somevalue
211-
# - SOMEOTHERENV=someothervalue
223+
# - SOMEENV=somevalue
224+
# - SOMEOTHERENV=someothervalue
212225

213226
# no_project_mount: false
214227
# (Experimental) If true, DDEV will not mount the project into the web container;
@@ -276,7 +289,7 @@ disable_upload_dirs_warning: true
276289
# Many DDEV commands can be extended to run tasks before or after the
277290
# DDEV command is executed, for example "post-start", "post-import-db",
278291
# "pre-composer", "post-composer"
279-
# See https://ddev.readthedocs.io/en/stable/users/extend/custom-commands/ for more
292+
# See https://docs.ddev.com/en/stable/users/extend/custom-commands/ for more
280293
# information on the commands that can be extended and the tasks you can define
281294
# for them. Example:
282295
#hooks:

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
runs-on: ubuntu-latest
1717
strategy:
1818
matrix:
19-
php: ['8.1', '8.2', '8.3']
19+
php: ['8.1', '8.2', '8.3', '8.4']
2020

2121
steps:
2222
- name: Checkout code

composer.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,25 @@
66
"license": "MIT",
77
"authors": [
88
{
9-
"name": "André Pimpão",
10-
"email": "a.pimpao@programmator.dev",
9+
"name": "Programmator",
10+
"email": "hotline@programmator.dev",
1111
"homepage": "https://programmator.dev"
1212
}
1313
],
1414
"require": {
1515
"php": ">=8.1",
16-
"myclabs/deep-copy": "^1.11",
17-
"programmatordev/php-api-sdk": "^1.0",
18-
"programmatordev/yet-another-php-validator": "^1.1"
16+
"myclabs/deep-copy": "^1.13",
17+
"programmatordev/php-api-sdk": "^2.1",
18+
"symfony/options-resolver": "^6.4|^7.3"
1919
},
2020
"require-dev": {
21-
"monolog/monolog": "^3.6",
21+
"monolog/monolog": "^3.9",
2222
"nyholm/psr7": "^1.8",
2323
"php-http/mock-client": "^1.6",
2424
"phpunit/phpunit": "^10.5",
25-
"symfony/cache": "^6.4",
26-
"symfony/http-client": "^6.4",
27-
"symfony/var-dumper": "^6.4"
25+
"symfony/cache": "^6.4|^7.3",
26+
"symfony/http-client": "^6.4|^7.3",
27+
"symfony/var-dumper": "^6.4|^7.3"
2828
},
2929
"provide": {
3030
"psr/http-client-implementation": "1.0",

docs/02-configuration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ $api = new OpenWeatherMap('yourapikey', [
7272
> To get to know about all the available methods, make sure to check the documentation [here](https://github.com/programmatordev/php-api-sdk?tab=readme-ov-file#documentation).
7373
7474
The following sections have examples of some of the most important methods,
75-
particularly related with the configuration of the client, cache and logger.
75+
particularly related to the configuration of the client, cache and logger.
7676

7777
### `setClientBuilder`
7878

docs/03-supported-apis.md

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
- [getWeather](#getweather)
66
- [getWeatherByDate](#getweatherbydate)
77
- [getWeatherSummaryByDate](#getweathersummarybydate)
8+
- [getWeatherOverviewByDate](#getweatheroverviewbydate)
9+
- [AI Assistant](#ai-assistant)
10+
- [startSession](#startsession)
11+
- [resumeSession](#resumesession)
812
- [Weather](#weather)
913
- [getCurrent](#getcurrent)
1014
- [getForecast](#getforecast)
@@ -68,6 +72,51 @@ Returns a [`WeatherSummary`](05-entities.md#weathersummary) object:
6872
$weatherSummary = $api->oneCall()->getWeatherSummaryByDate(50, 50, new \DateTime('1985-07-19'));
6973
```
7074

75+
#### `getWeatherOverviewByDate`
76+
77+
```php
78+
getWeatherOverviewByDate(float $latitude, float $longitude, \DateTimeInterface $date): WeatherOverview
79+
```
80+
81+
Get the weather overview with a human-readable summary for today and tomorrow's forecast,
82+
using OpenWeather AI.
83+
84+
Returns a [`WeatherOverview`](05-entities.md#weatheroverview) object:
85+
86+
```php
87+
$weatherOverview = $api->oneCall()->getWeatherOverviewByDate(50, 50, new \DateTime('today'));
88+
```
89+
90+
### AI Assistant
91+
92+
#### `startSession`
93+
94+
```php
95+
startSession(string $prompt): Answer
96+
```
97+
98+
Start a new session (create a new conversation) with the Weather AI Assistant.
99+
100+
Returns a [`Answer`](05-entities.md#answer) object:
101+
102+
```php
103+
$answer = $api->assistant()->startSession('How is the weather today in Lisbon?');
104+
```
105+
106+
#### `resumeSession`
107+
108+
```php
109+
resumeSession(string $sessionId, string $prompt): Answer
110+
```
111+
112+
Resume a session (continue a conversation) with the Weather AI Assistant.
113+
114+
Returns a [`Answer`](05-entities.md#answer) object:
115+
116+
```php
117+
$answer = $api->assistant()->resumeSession('session-id', 'Do I need an umbrella?');
118+
```
119+
71120
### Weather
72121

73122
#### `getCurrent`
@@ -176,7 +225,7 @@ $locations = $api->geocoding()->getByLocationName('lisbon');
176225
getByCoordinate(float $latitude, float $longitude, int $numResults = 5): array
177226
```
178227

179-
Get name of the location (city name or area name) by using geographical coordinates (latitude, longitude).
228+
Get the name of the location (city name or area name) by using geographical coordinates (latitude, longitude).
180229

181230
Returns an array of [`Location`](05-entities.md#location) objects.
182231

@@ -245,7 +294,7 @@ withCacheTtl(?int $ttl): self
245294
Makes a request and saves into cache for the provided duration in seconds.
246295

247296
Semantics of values:
248-
- `0`, the response will not be cached (if the servers specifies no `max-age`).
297+
- `0`, the response will not be cached (if the server specifies no `max-age`).
249298
- `null`, the response will be cached for as long as it can (forever).
250299

251300
> [!NOTE]

docs/04-error-handling.md

Lines changed: 6 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
# Error Handling
22

3-
- [API Errors](#api-errors)
4-
- [Validation Errors](#validation-errors)
5-
63
## API Errors
74

85
To handle API response errors, multiple exceptions are provided. You can see all available in the following example:
@@ -15,13 +12,9 @@ use ProgrammatorDev\OpenWeatherMap\Exception\UnauthorizedException;
1512
use ProgrammatorDev\OpenWeatherMap\Exception\UnexpectedErrorException;
1613

1714
try {
18-
$location = $api->geocoding()->getByZipCode('1000-001', 'pt');
19-
$coordinate = $location->getCoordinate();
15+
// ...
2016

21-
$weather = $api->oneCall()->getWeather(
22-
$coordinate->getLatitude(),
23-
$coordinate->getLongitude()
24-
);
17+
$weather = $api->oneCall()->getWeather($latitude, $longitude);
2518
}
2619
// bad request to the API
2720
catch (BadRequestException $exception) {
@@ -33,7 +26,7 @@ catch (UnauthorizedException $exception) {
3326
echo $exception->getCode(); // 401
3427
echo $exception->getMessage();
3528
}
36-
// resource not found
29+
// resource not found,
3730
// for example, when trying to get a location with a zip code that does not exist
3831
catch (NotFoundException $exception) {
3932
echo $exception->getCode(); // 404
@@ -57,35 +50,13 @@ To catch all API errors with a single exception, `ApiErrorException` is availabl
5750
use ProgrammatorDev\OpenWeatherMap\Exception\ApiErrorException;
5851

5952
try {
60-
$location = $api->geocoding()->getByZipCode('1000-001', 'pt');
61-
$coordinate = $location->getCoordinate();
62-
63-
$weather = $api->oneCall()->getWeather(
64-
$coordinate->getLatitude(),
65-
$coordinate->getLongitude()
66-
);
53+
// ...
54+
55+
$weather = $api->oneCall()->getWeather($latitude, $longitude);
6756
}
6857
// catches all API response errors
6958
catch (ApiErrorException $exception) {
7059
echo $exception->getCode();
7160
echo $exception->getMessage();
7261
}
73-
```
74-
75-
## Validation Errors
76-
77-
To catch invalid input data (like an out of range coordinate, blank location name, etc.), the `ValidationException` is available:
78-
79-
```php
80-
use ProgrammatorDev\Validator\Exception\ValidationException;
81-
82-
try {
83-
// an invalid latitude value is given
84-
$weather = $api->weather()->getCurrent(999, 50);
85-
}
86-
catch (ValidationException $exception) {
87-
// should print:
88-
// The latitude value should be between -90 and 90, 999 given.
89-
echo $exception->getMessage();
90-
}
9162
```

0 commit comments

Comments
 (0)