Startup API/Installation

One of the important goals for the project are simple installation and upgrades. Let us know where you experience problems and we'll try to reduce the friction.

When you unpack the code into users folder, open it in your browser and installation wizard will walk you through the process.

Prerequisites
Startup API uses PHP 5.3.0 or newer, after all it was released on 6/30/2009.

It also requires a few common extensions that might not be installed on your LAMP server. Click the links for installation instructions:
 * php-mysqli for support of more performant and secure MySQL interface
 * php-mcrypt encryption library for better security
 * libcurl / cURL for various network operations
 * php-mbstring for international strings support (user names, for example)

From Git repository
Get the code from GitHub and place into the root directory of your website.

The following command places Startup API in the users folder (recommended default): git clone git://github.com/StartupAPI/users.git users

If you already use Git for your code, you can use StartupAPI as a submodule: git submodule add git://github.com/StartupAPI/users.git users

NOTE: A submodule can only be added from your git repository root directory. If your WEBROOT is not the root directory you can specify the applicable directory, e.g. www/users

Downloadable packages
If you do not use Git, you can just download latest package from package archive section.

Create MySQL database
If you don't have it yet, create MySQL database and get user credentials for it with following permissions: CREATE, ALTER, CREATE TEMPORARY TABLES, DELETE, DROP, INDEX, INSERT, SELECT, UPDATE.

mysql> CREATE SCHEMA IF NOT EXISTS example_schema; mysql> CREATE USER schema_user@localhost IDENTIFIED BY 'password'; mysql> GRANT INSERT,UPDATE,DELETE,SELECT,CREATE,ALTER,DROP,CREATE TEMPORARY TABLES ON example_schema.* TO schema_user@localhost;

Some of these permissions (CREATE, ALTER, DROP, INDEX) are needed for creating database schema and can be removed after the installation step has been completed.

CREATE TEMPORARY TABLES is required for aggregatepoints.php script.

There is an issue #79 open for separating admin credentials (for schema manipulation) from application credentials. Why it is important to do so, see here: Why GRANT ALL is bad by Ronald Bradford.

Create configuration file
Copy the sample configuration file from the installed users folder to the base directory of your website. cp users/users_config.sample.php users_config.php

Open the users_config.php file with your favorite editor, and as minimum, seed the secret for cookie encryption and set your defined MySQL database credentials

Build code and schema
Run make to generate database tables and other submodules and files required by the different parts of Startup API. cd users make

When completed you will see the following ... Upgraded to v.26 Upgraded to v.27 php aggregatepoints.php

Without make
If you do not have make installed on your system, you can get the latest downloadable package (which contains all files including submodules) instead of checking code out of the repository.

For schema setup, just run

cd users php dbupgrade.php

open  /users/dbupgrade.php in your browser - this will create database schema (or update it if you already have older version).

Configure authentication modules
Uncomment and configure API keys for more authentication modules for Facebook, Twitter, Google and etc.

Complete Installation
You should now in a browser goto http://yourwebsite.com/users and complete the installation via the provided Wizard.

Use it
Start building your app by copying code from sample.php.

Global code
Basically, you'll need to include `users.php` above any other output

and then include a call to  function in your HTML   tag to include some global styles and scripts controlled by StartupAPI and it's modules.

Get a User
and then use either User::get static method to get a user object

or if you want to protect the page from anonymous users, use User::require_login instead - this will automatically redirect to a login form and back to yout page after user successfully logged in or registered.

you can get numeric user ID to use in your data model by calling getID method

Power Strip
You will most likely want to show a login menu in the top-right corner of your page. You can do it by simply calling  function like so:

Use Accounts
It is recommended to use s instead of  s to associate your data. This way you'll be able to upgrade your initial single-user setup to multi-user accounts and work with subscription payments in the future without changing any of your code, just Startup API configuration. Each user gets one free account associated with them by default so it is the same as using users out of the box.

Similarly to s,  s have unique integer IDs associated with them so you can display data associated with user's current account:

or you can get a list of all user accounts:

Now what?
Sit back and relax Go implement your business logic now. You can call getID, getName</tt> and other methods on the user object to utilize it in your code.

Upgrading
As usual, make a backup of the database to avoid loosing data in case of disasters.

Then just run make - it should grab the latest code and run database update scripts to bring schema up to date with the code. make