2017 © Pedro Peláez
 

symfony-bundle tools-bundle

Symfony JeffBdnToolsBundle

image

jeffbdn/tools-bundle

Symfony JeffBdnToolsBundle

  • Friday, August 25, 2017
  • by jeffbdn
  • Repository
  • 1 Watchers
  • 0 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Installation

Step 1: Download the Bundle

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:, (*1)

$ composer require jeffbdn/tools-bundle "~1"

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation., (*2)

Step 2: Enable the Bundle

Then, enable the bundle by adding it to the list of registered bundles in the app/AppKernel.php file of your project:, (*3)

<?php
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...

            new JeffBdn\ToolsBundle\JeffBdnToolsBundle(),
        );

        // ...
    }

    // ...
}

This bundle comes with several services. In order to make them available for your project, register the bundle's services.yml file in your config.yml:, (*4)

# app/config/config.yml
imports:
    ...
    - { resource: "@JeffBdnToolsBundle/Resources/config/services.yml" }

Then, add and customise those parameters in your config.yml:, (*5)

# app/config/config.yml
parameters:
      jeffbdn_tools.weather.apikey: 'PASTE HERE YOUR openweathermaps API KEY'
      jeffbdn_tools.weather.refresh: '3 minutes' # or 1 day or 2 days or 1 hour or 2 hours or 1 minute or 2 minutes

jeffbdn_tools.weather.apikey: In order to use the Weather Service, you will need an OpenWeatherMaps API Key. You can get one for free by creating a new account on https://home.openweathermap.org/users/sign_up ., (*6)

jeffbdn_tools.weather.refresh: You can choose the refresh rate for the broadcast for all locations. The cache will be renewed on next call if the data get older than the amount of time your precised., (*7)

Step 3: Use the Tools

The current version of JeffBdnToolsBundle provides 2 services:, (*8)

  • A random number provider
$randomNumber = $this->get('jeffbdn_tools.math')->random();
  • A weather broadcast provider
$weatherBroadcast = $this->get('jeffbdn_tools.weather')->broadcast('Paris,fr');

The data you may be interested to use are:, (*9)

  • Temperatures in Kelvin, Celsius, Fahrenheit
$weatherBroadcast['temp_k']
$weatherBroadcast['temp_k_min']
$weatherBroadcast['temp_k_max']

```php $weatherBroadcast['temp_c'] $weatherBroadcast['temp_c'] $weatherBroadcast['temp_c_max'], (*10)

```php
$weatherBroadcast['temp_f']
$weatherBroadcast['temp_f_min']
$weatherBroadcast['temp_f_max']
  • Sky and Atmosphere details:
$weatherBroadcast['humidity']
$weatherBroadcast['sky_description_short']
$weatherBroadcast['sky_description_long']
$weatherBroadcast['pressure_hpa']
$weatherBroadcast['wind_speed_metersec']
$weatherBroadcast['cloud_percent']
  • Date of last update, sunrise and sunset:
$weatherBroadcast['date']
$weatherBroadcast['sunrise']
$weatherBroadcast['sunset']
  • Error Management:
// true if API call went well, else false
$weatherBroadcast['ok']
// this is the HTTP response code, default is 200
$weatherBroadcast['error_code']
// this is the API response message, default is an empty string
$weatherBroadcast['error_string']

Step 4: Testing the ToolsBundle

$ phpunit vendor/jeffbdn/tools-bundle/JeffBdn/ToolsBundle/Tests/Weather.php

If you encounter any bug, please report on http://www.github.com/jeffbdn/tools-bundle/issues, (*11)

The Versions

25/08 2017

dev-master

9999999-dev https://github.com/jeffbdn/tools-bundle

Symfony JeffBdnToolsBundle

  Sources   Download

MIT

The Requires

 

by Jean-Francois BAUDRON

toolbox

25/08 2017

dev-remotes/origin/dev

dev-remotes/origin/dev https://github.com/jeffbdn/tools-bundle

Symfony JeffBdnToolsBundle

  Sources   Download

MIT

The Requires

 

by Jean-Francois BAUDRON

toolbox

26/07 2017