Coder Social home page Coder Social logo

iroman1 / geonames Goto Github PK

View Code? Open in Web Editor NEW

This project forked from michaeldrennen/geonames

0.0 0.0 0.0 3.15 MB

A Laravel (php) package to interface with the geo-location services at geonames.org.

License: MIT License

PHP 98.36% Blade 1.64%

geonames's Introduction

geonames v7.x

Latest Stable Version Total Downloads License GitHub issues GitHub forks GitHub stars Travis (.org)

A Laravel (php) package to interface with the geo-location services at geonames.org.

Major Version Jump

I jumped several major versions to catch up with Larvel's major version number. Makes things a little clearer.

Notes

There is still a lot that needs to be done to make this package "complete". I've gotten it to a point where I can use it for my next project. As time allows, I will improve the documentation and testing that comes with this package. Thanks for understanding.

Installation

composer require michaeldrennen/geonames

And then add geonames provider to providers array in app.php config file:

MichaelDrennen\Geonames\GeonamesServiceProvider::class,

After that, Run migrate command:

php artisan migrate

Want to install all of the geonames records for the US, Canada, and Mexico as well as pull in the feature codes definitions file in English?

php artisan geonames:install --country=US --country=CA --country=MX --language=en

Want to just install everything in the geonames database?

php artisan geonames:install

Maintenance

Now that you have the geonames database up and running on your system, you need to keep it up-to-date.

I have an update script that you need to schedule in Laravel to run every day.

Some info on how to schedule Laravel artisan commands:

https://laravel.com/docs/5.6/scheduling#scheduling-artisan-commands

You can read this notice at: http://download.geonames.org/export/dump/

The "last modified" timestamp is in Central European Time.

It looks like geonames updates their data around 3AM CET.

So if you schedule your system to run the geonames:update artisan command after 4AM CET, you should be good to go.

I like to keep my servers running on GMT. Keeps things consistent.

(Central European Time is 1 hour ahead of Greenwich Mean Time)

Assuming your servers are running on GMT, your update command would look like:

$schedule->command('geonames:update')->dailyAt('3:00');

The update artisan command will handle the updates and deletes to the geonames table.

Gotchas

Are you getting something like: 1071 Specified key was too long

@see https://laravel-news.com/laravel-5-4-key-too-long-error

Add this to your AppServiceProvider.php file:

Schema::defaultStringLength(191);

A quick word on indexes

This library contains a bunch of migrations that contain a bunch of indexes. Now not everyone will need all of the indexes.

So when you install this library, run the migrations and delete the indexes that you don't need.

Also, Laravel doesn't let you specify a key length for indexes on varchar columns. There are two indexes suffering from this limit. Instead of creating indexes on those columns the "Laravel way", I send a raw/manual query to create the indexes with the proper lengths.

geonames's People

Contributors

michaeldrennen avatar karlshea avatar mikrafizik avatar maherelgamil avatar victorlap avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.