Note: If you've already installed laravel to your project, skip to the Step 3.
Let's say that we name our project "my_project". So now we actually have an empty folder.
Install Laravel. In our case we are simply using the composer command:
composer create-project laravel/laravel --prefer-dist
Follow all the instructions of the laravel installation guide such as configurations, permissions, pretty URLs... e.t.c. If you have any issues with the installation , ask laravel's community
At the end of the installation, you should have something like the below folder structure (my_project/laravel):
app artisan bootstrap public vendor CONTRIBUTING.md composer.json composer.lock phpunit.xml readme.md server.php
Make sure that all your configurations are pointing to the laravel project. For now we will just use an example domain that it will point at local.my_project.com. For the references only, I am using apache with virtual hosts, so I've added the below configurations to my httpd-vhosts.conf (I am using MAMP)
NameVirtualHost *:8888DocumentRoot "/private/var/www/test/my_project/laravel/public" ServerName local.my_project.com
Now if everything goes well (that I hope it will!), you will see the You have arrived message in your browser by typing http://local.my_project.com (or http://local.my_project.com:8888 at MAMP)
As the full installation of Laravel is not the purpose of this guide. If you have any questions, please ask: stackoverflow, laravel's community or a friend :)
So now add the below line at the "require" section:
"grocerycrud/imagecrud-laravel": "0.7.*"
An example of how the composer.json will look like is:
{ "name": "laravel/laravel", "description": "The Laravel Framework.", "keywords": ["framework", "laravel"], "license": "MIT", "require": { "laravel/framework": "4.1.*", "grocerycrud/imagecrud-laravel": "0.7.*" }, ... "minimum-stability": "stable" }
So now simply run:
composer update
and wait...
If everything goes well, you should see something like this:
Loading composer repositories with package information Updating dependencies (including require-dev) - Installing grocerycrud/imagecrud-laravel (0.7.0) Loading from cache Writing lock file Generating autoload files Generating optimized class loader Compiling common classes
Now theoritically we've installed image CRUD to our project as a composer package. In order to actually install it to our project we need few more steps.
That's simple! Just copy the assets folder (you will find it at: /your_project_path/vendor/grocerycrud/imagecrud-laravel/assets) to your public folder (in our case /your_project_path/public/assets).
At the end of the copy, the folder structure will look something like:
Congrats! You've just installed image CRUD to your project. There are few things that you need to get started with image CRUD first. Let's see an example of how to implement grocery CRUD in your controller
use ImageCrud\Core\ImageCrud; .... $crud = new ImageCrud();
use ImageCrud\Core\ImageCrud; class ExampleController extends BaseController { /** * The layout that should be used for responses. */ protected $layout = 'layout'; public function postExample1() { return $this->getExample1(); } public function getExample1() { $image_crud = new ImageCRUD(); $image_crud->set_primary_key_field('id'); $image_crud->set_url_field('url'); $image_crud->set_table('example_1') ->set_image_path('assets/uploads'); $output = $image_crud->render(); return $this->_example_output($output); } private function _example_output($output = null) { return View::make('example', $output); } }
Now at the example above, if we simply print_r of the $output, we will have an output that it will look pretty much as grocery CRUD's $output
If you would like to see some example controllers/config/views you can actually have a look of some examples
Copy the Examples folder to your app folder. Don't forget to add the routes and the database config.
Import the example database
Play with the examples and enjoy