Download the PHP package csabourin/meteocraft without Composer
On this page you can find all versions of the php package csabourin/meteocraft. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package meteocraft
Ottawa Weather Display Component
Simple, accessible weather display component for Ottawa, Ontario, using data from Environment and Climate Change Canada (ECCC). Built for Craft CMS 5 with PHP in Twig support.
Features
- Self-Contained: Single Twig template with embedded PHP - no plugin required
- Current Weather: Real-time temperature, humidity, wind, pressure, and conditions
- Today's Forecast: Weather breakdown by time period (morning, afternoon, evening)
- Bilingual: Full English and French support with translations
- Accessible: WCAG 2.1 AA compliant with semantic HTML and ARIA labels
- Customizable: SCSS file with variables for easy theming
- Cached: 30-minute cache to optimize API calls
- Official Data: Environment and Climate Change Canada API
Requirements
- Craft CMS 5.x
- PHP 8.0 or higher
- PHP in Twig (Twig Perversion) enabled
- cURL extension
Installation
1. Copy Files to Your Craft Project
Copy the files from this repository to your Craft installation:
2. Register Translations in Your Module
Add the translation category to your module's config/app.php:
Or if you prefer, add it directly in your module's init() method:
3. Import SCSS
Add to your main stylesheet:
Customize Colors
Define variables before importing:
Usage
Basic Usage
Include the template anywhere in your Twig files:
With Options
Example Integrations
In a Layout
In a Page Template
File Structure
Configuration
Cache Duration
Edit the PHP block in templates/_weather/display.twig:
Customizing Display
The template is fully editable. Modify templates/_weather/display.twig to:
- Change layout and styling
- Add or remove weather data points
- Adjust time periods (currently: morning 6am-12pm, afternoon 12pm-6pm, evening 6pm-12am)
Translations
Edit the translation files to customize any text:
translations/en/weather.php- Englishtranslations/fr/weather.php- French
Data Source
- API: Environment and Climate Change Canada (ECCC)
- Endpoint:
https://api.weather.gc.ca/collections/citypageweather-realtime - Documentation: ECCC Open Data
- Location: Ottawa (Kanata - Orléans)
Accessibility
This component is WCAG 2.1 Level AA compliant:
- ✓ Proper semantic HTML5 elements
- ✓ ARIA labels and roles
- ✓ Keyboard accessible
- ✓ Screen reader friendly
- ✓ High contrast ratios (4.5:1+)
- ✓ Bilingual support
See ACCESSIBILITY.md for details.
Troubleshooting
Template shows "Unable to load weather data"
- Verify server has internet connectivity
- Check cURL is enabled:
php -m | grep curl - Ensure PHP in Twig is enabled in your Craft config
- Check logs:
storage/logs/web.log - Clear cache:
./craft clear-caches/all
Translations not working
- Verify translations are registered in
config/app.phpor your module - Check file paths match your module structure
- Clear cache:
./craft clear-caches/all - Verify translation category is 'weather' (not 'meteocraft')
Styling not applied
- Verify SCSS file is imported in your main stylesheet
- Check file path is correct
- Rebuild your CSS:
npm run buildor your build command - Clear browser cache
License
MIT License - see LICENSE file
Credits
- Weather data: Environment and Climate Change Canada
- Component by: csabourin
Support
For issues or questions: GitHub Repository
Alternative: Using with Your Existing Controller
If you prefer to use your existing controller's actionFetchJson() method instead of the embedded PHP, you can modify the template to make an AJAX call:
However, note that your current controller only allows services2.arcgis.com in the allowlist, so you'd need to add api.weather.gc.ca to use it for weather data.