Download the PHP package fndmiranda/simple-address without Composer

On this page you can find all versions of the php package fndmiranda/simple-address. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package simple-address

Art of README

This article can also be read in Brazilian Portuguese.

Simple address from Laravel

This package simplifies the search for addresses by zip code in Api`s and the management of addresses in the database, you can also create your own adapters for api queries.

Installation

Usage

Publish the package configuration file with vendor:publish Artisan command:

The published configuration file address.php will be placed in your config directory.

Api`s of search

The list of Api's available is located in your config/address.php file in apis and you can remove or add new adapters as follows:

If you change force_priority in config/address.php to true the search order will always conform to the list of apis adapters, by default this value is false for the order to be random.

With the search method on the facade of the Address the package will loop in the apis until finding the requested postcode as follows:

Geocoding

You can use the data returned by the search method to obtain the latitude and longitude of the address with the geocoding method of the facade Address as follows:

Note, to use the geocoding feature you need to provide the Google Maps API key, add the ADDRESS_GOOGLE_MAPS_KEY entry in your .env file as follows:

Database

This package comes with a complete database structure to store the searched addresses.

Note that a table for polymorphism will be created, which should be created with the type of column that will make the relation the same that you use in your tables by setting the column_type in the config/address.php file and the options are integer, bigInteger and uuid there then create the tables with migrate Artisan command:

Migration Customization

If you are not going to use SimpleAddress default migrations, you should call the Address::ignoreMigrations method in the register method of your AppServiceProvider. You may export the default migrations using vendor:publish Artisan command:

If you do not want to manage the addresses in the database and just want to query in api, change the config/address.php file manager_address to false.

Saving in database

Example of integration of supplier model with address polymorphism.

You can then save the address to a supplier by using the search and geocoding methods of the facade Address as in the following example:

Or in your controller

Request body example

Creating your custom adapter

You can create your own custom adapter to query an API that is not in the list, you may generate an adapter of the simple-address:make Artisan command:

This command will generate a adapter at app/SimpleAddress/Adapters/YourApiAdapter.php.

The file will contain the empty search andprepare methods, so you can adapt them by following the file structure as in the following example:

Add your adapter to the apis list in the config/address.php file as follows:

If you create a new Api adapter, I would appreciate if you open a pull request by adding your adapter and mapping it in the apis list in config/address.php of the package.

Method search

The search method sends the request to an endpoint to query a postcode and uses the prepare method to transform the obtained data into a standard array and returns them or returns false if the postcode is not found or if api does not respond so that it automatically query on the next api adapter.

Method prepare

The prepare method will transform the data returned by an api into a standard array with the keys postcode, address, neighborhood, city and state.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

License

The MIT License (MIT). Please see License File for more information.


All versions of simple-address with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0.0
illuminate/support Version ~5.0|^7.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package fndmiranda/simple-address contains the following files

Loading the files please wait ....