Download the PHP package andrewmile/fm-laravel without Composer

On this page you can find all versions of the php package andrewmile/fm-laravel. 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 fm-laravel

Installation

Install the Laravel framework

You will need the Composer PHP package manager to install Laravel and FMLaravel. You can install Composer from getcomposer.org

If you do not yet have the Laravel framework installed you will need to install Laravel by running the following command in terminal:

composer create-project laravel/laravel YourProjectName

Once Composer finishes the instalation you will need to give Laravel write access to the storage directory by running the following command in terminal:

chmod -R 777 storage

Instal FMLaravel

In your text editor open composer.json and add the following line to the "require" section of the file. This will tell Composer that your project requires FMLaravel.

"andrewmile/fm-laravel": "0.4.*"

Run the following command in terminal to install FMLaravel

composer update

Config

Back in your text editor open config/app.php and add the following line to the providers array:

'FMLaravel\Database\FileMakerServiceProvider',

In config/database.php change the default connection type to filemaker:

'default' => 'filemaker',

Still in config/database.php add the following to the connections array:

'filemaker' => [
    'driver'   => 'filemaker',
    'host'     => env('DB_HOST'),
    'database' => env('DB_DATABASE'),
    'username' => env('DB_USERNAME'),
    'password' => env('DB_PASSWORD'),
],

In your root directory create a new file named .env and add the following while including your database connection details:

DB_HOST=YourHost
DB_DATABASE=YourDatabase
DB_USERNAME=YourUsername
DB_PASSWORD=YourPassword

Note that if you are using version control you do not want the .env file to be a part of your repository so it is included in .gitignore by default.

Usage

Creating a Model

Laravel includes a command line tool called artisan that you can use for many helpful tasks, including generating files to avoid typing repetative boilerplate code.

You will want to have one model class per table that you are using in your project. Laravel uses a convention where it uses singular model names. To create a model for a tasks table run the following command in terminal:

php artisan make:model Task

The file that was generated for you is located at app/Task.php. This class extends Laravel's Eloquent Model class but we need it to extend the FMLaravel Model class instead. Delete the following line from the newly created Task.php file:

use Illuminate\Database\Eloquent\Model;

Then add the following line in its place:

use FMLaravel\Database\Model;

In your Model classes you will need to specify the layout that should be used when querying the tasks table in your FileMaker database. In order to do this add the following line inside the Task class:

protected $layoutName = 'YourTaskLayoutName';

By default Laravel will assume the primary key of your table is "id". If you have a different primary key you will need to add the following inside your class:

protected $primaryKey = 'YourTaskPrimaryKey';

Querying a table

In a file where you will query your FileMaker tasks data add the following at the top of the file:

use App\Task;

Now that you have imported your Task model you can run the following types of queries against your tasks table:

Find all records

$tasks = Task::all();

Find a record by its primary key

$task = Task::find(3); //will find the task record with a primary key of 3

Find a task that matches your find criteria. You can either pass in two parameters where the first is the field name and the second is the value to match on or you can pass in an array of field names and values.

//will find tasks where the task_name is 'Go to the store'
$tasks = Task::where('task_name', 'Go to the store')->get();

//will find tasks where task_name is 'Go to the store' and priority is 1
$tasks = Task::where([
    'task_name' => 'Go to the store',
    'priority'  => 1
])->get();

If you want to limit your query to the first record that matches your criteria you can use first() instead of get()

$tasks = Task::where('task_name', 'Go to the store')->first();

If you want to specify a number of records to limit your query by you can use the limit() method.

//will find the first 10 records that match the find criteria
$tasks = Task::where('task_name', 'Go to the store')->limit(10)->get();

You can also specify a number of records to skip with the skip() method.

//will find records that match the find criteria after skipping the first 10
$tasks = Task::where('task_name', 'Go to the store')->skip(10)->get();

These query methods can be chained so you can do something like the following:

//will find 10 records that match the find criteria after skipping the first 100
$tasks = Task::where('task_name', 'Go to the store')->skip(100)->limit(10)->get();

If you are using both skip() and limit() in the same query and would rather combine them into one method you can also use the following:

//will find 10 records that match the find criteria after skipping the first 100
$tasks = Task::where('task_name', 'Go to the store')->setRange(100, 10)->get();

By default the layout you set on the $layoutName property of your model will be used to query your data. However, if you need to specify a different layout for a specific query you may use the setLayout() method.

//will use the PastDue layout to perform the query
$tasks = Task::where('task_name', 'Go to the store')->setLayout('PastDue')->get();

To Dos


All versions of fm-laravel with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
andrewmile/fm-hash Version 0.1.*
andrewmile/fm-api Version 0.1.2
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 andrewmile/fm-laravel contains the following files

Loading the files please wait ....