dirkgroenen / pinterest-api-php

A PHP wrapper for the official Pinterest API. :pushpin:
https://developers.pinterest.com/docs/getting-started/introduction/
Apache License 2.0
173 stars 76 forks source link

Autoload in index.php file #36

Closed compworkmail closed 8 years ago

compworkmail commented 8 years ago

Hello. I want to advice you to add to the examples, for example to index.php file which is in the root of the site next code to autoload all the classes:

<?php

use DirkGroenen\Pinterest\Pinterest;

require_once(DIR . '/src/Pinterest/Pinterest.php');

function autoload($class_name) { $class_name = str_replace('\', '/', $class_name); $class_name = str_replace('DirkGroenen/', '', $class_name); require_once(__DIR . "/src/$class_name.php"); }

$pinterest = new Pinterest('your_id', 'your_secret');

This code is ready to work and developers don't need to add each file like: require_once('curl'); require_once('auth'); ... etc.

dirkgroenen commented 8 years ago

You're aware Composer does this job for you? After installing the package with composer you only have to include the autoload.php file and all classes will be available.

compworkmail commented 8 years ago

Oh, thanks, I didn't know about Composer's feature