Git Product home page Git Product logo

aimeos-laravel's Introduction

Aimeos logo

Aimeos Laravel package

Build Status Scrutinizer Code Quality HHVM Status

The repository contains the web shop package for Laravel 5 integrating the Aimeos e-commerce library into Laravel. The package provides controllers for e.g. faceted filter, product lists and detail views, for searching products as well as baskets and the checkout process. A full set of pages including routing is also available for a quick start.

Table of content

Installation

The Aimeos Laravel web shop package is a composer based library that can be installed easiest by using Composer. Before, the Aimeos provider class must be added to the providers array of the config/app.php file so the composer post install/update scripts won't fail:

return array(
    'providers' => array(
        ...
        'Aimeos\Shop\ShopServiceProvider',
    ),
);

Make sure that the database is set up and it is configured in your config/database.php or .env file (depending on the Laravel version). Then add these lines to your composer.json of your Laravel project:

    "repositories": [ {
        "type": "vcs",
        "url": "https://github.com/aimeos/arcavias-core"
    } ],
    "prefer-stable": true,
    "minimum-stability": "dev",
    "require": {
        "aimeos/aimeos-laravel": "dev-master",
        ...
    },
    "scripts": {
        "post-install-cmd": [
            "php artisan vendor:publish",
            "php artisan migrate",
            "php artisan aimeos:setup --option=setup/default/demo:1",
            "php artisan aimeos:cache",
            ...
        ],
        "post-update-cmd": [
            "php artisan vendor:publish",
            "php artisan migrate",
            "php artisan aimeos:setup --option=setup/default/demo:1",
            "php artisan aimeos:cache",
            ...
        ]
    }

Afterwards, install the Aimeos shop package using

composer update

In a production environment or if you don't want that the demo data gets installed, leave out the --option=setup/default/demo:1 option.

Setup

To see all components and get everything working, you also need to adapt your main Blade template in resources/views/app.blade.php. This is a working example using the Twitter bootstrap CSS framework:

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">
@yield('aimeos_header')
	<title>Laravel</title>

    <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet">
@yield('aimeos_styles')
	<link href="/css/app.css" rel="stylesheet">
	<!-- Fonts -->
	<link href='//fonts.googleapis.com/css?family=Roboto:400,300' rel='stylesheet' type='text/css'>

	<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
	<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
	<!--[if lt IE 9]>
		<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
		<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
	<![endif]-->
</head>
<body>
	<nav class="navbar navbar-default">
@yield('aimeos_head')
	<div class="container-fluid">
			<div class="navbar-header">
				<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
					<span class="sr-only">Toggle Navigation</span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
				</button>
				<a class="navbar-brand" href="#">Laravel</a>
			</div>

			<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
				<ul class="nav navbar-nav">
					<li><a href="/">Home</a></li>
				</ul>

				<ul class="nav navbar-nav navbar-right">
					@if (Auth::guest())
						<li><a href="/auth/login">Login</a></li>
						<li><a href="/auth/register">Register</a></li>
					@else
						<li class="dropdown">
							<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">{{ Auth::user()->name }} <span class="caret"></span></a>
							<ul class="dropdown-menu" role="menu">
								<li><a href="/auth/logout">Logout</a></li>
							</ul>
						</li>
					@endif
				</ul>
			</div>
		</div>
	</nav>
    <div class="col-xs-12">
@yield('aimeos_nav')
@yield('aimeos_stage')
@yield('aimeos_body')
@yield('aimeos_aside')
@yield('content')
	</div>

	<!-- Scripts -->
	<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
	<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.1/js/bootstrap.min.js"></script>
@yield('aimeos_scripts')
	</body>
</html>

Note: Since Laravel 5.0 CSRF protection is enabled by default but the Aimeos web shop package is not yet prepared to use it. You have to disable the global CSRF protection and enable it manually for specific routes for now. For that purpose, move the App\Http\Middleware\VerifyCsrfToken line in your app/Http/Kernel.php from the $middleware to the $routeMiddleware array as 'csrf' => 'App\Http\Middleware\VerifyCsrfToken':

	protected $middleware = [
		'Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode',
		'Illuminate\Cookie\Middleware\EncryptCookies',
		'Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse',
		'Illuminate\Session\Middleware\StartSession',
		'Illuminate\View\Middleware\ShareErrorsFromSession',
	];

	protected $routeMiddleware = [
		'auth' => 'App\Http\Middleware\Authenticate',
		'auth.basic' => 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth',
		'guest' => 'App\Http\Middleware\RedirectIfAuthenticated',
		'csrf' => 'App\Http\Middleware\VerifyCsrfToken',
	];

Afterwards, you should clear the Laravel cache files. Otherwise, you might get an exception due to old cached data.

php artisan cache:clear

Then, you should be able to call the catalog list page in your browser. For a quick start, you can use the integrated web server that is available since PHP 5.4. Simply execute this command in the base directory of your application:

php -S 127.0.0.1:8000 -t public

Afterwards, you will be able to open the list page of the shop in your browser using:

http://127.0.0.1:8000/index.php/list

or for the administration interface:

http://127.0.0.1:8000/index.php/admin

Caution: You need to protect the /admin routes so only editors are able to access them. This is especially crucial as it grants direct access to the administration interface where you can manage your shop!

Hints

To simplify development, you should configure to use no content cache. You can do this in the config/shop.php file of your Laravel application by adding these lines at the bottom:

    'classes' => array(
        'cache' => array(
            'manager' => array(
                'name' => 'None',
            ),
        ),
    ),

License

The Aimeos Laravel package is licensed under the terms of the MIT license and is available for free.

Links

aimeos-laravel's People

Contributors

aimeos avatar scrutinizer-auto-fixer avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.