Coder Social home page Coder Social logo

yii2-shop's Introduction

Yii 2 shop example project

This is an example project implementing a shop created to help people learn Yii 2.0. It was created during 8 hours workshop performed in Ekaterinburg, Russia. The idea was to show how to deal with Gii, grids, filtering and other Yii 2.0 usage. It is by no means a complete shop script. It may contain bugs, shortcuts etc.

If you want to take over the project and develop it further, let @samdark know and you'll be granted permissions required.

There are slides from the workshop in Russian: http://slides.rmcreative.ru/2014/yii2-master/

It is built on top of advanced template which includes three tiers: front end, back end, and console, each of which is a separate Yii application.

DIRECTORY STRUCTURE

common
    config/              contains shared configurations
    mail/                contains view files for e-mails
    models/              contains model classes used in both backend and frontend
console
    config/              contains console configurations
    controllers/         contains console controllers (commands)
    migrations/          contains database migrations
    models/              contains console-specific model classes
    runtime/             contains files generated during runtime
backend
    assets/              contains application assets such as JavaScript and CSS
    config/              contains backend configurations
    controllers/         contains Web controller classes
    models/              contains backend-specific model classes
    runtime/             contains files generated during runtime
    views/               contains view files for the Web application
    web/                 contains the entry script and Web resources
frontend
    assets/              contains application assets such as JavaScript and CSS
    config/              contains frontend configurations
    controllers/         contains Web controller classes
    models/              contains frontend-specific model classes
    runtime/             contains files generated during runtime
    views/               contains view files for the Web application
    web/                 contains the entry script and Web resources
    widgets/             contains frontend widgets
vendor/                  contains dependent 3rd-party packages
environments/            contains environment-based overrides
tests                    contains various tests for the advanced application
    codeception/         contains tests developed with Codeception PHP Testing Framework

REQUIREMENTS

The minimum requirement by this application template that your Web server supports PHP 5.4.0.

INSTALLATION

Install via Composer

If you do not have Composer, you can install it by following the instructions at getcomposer.org.

You can then install the application using the following command:

git clone https://github.com/samdark/yii2-shop.git
composer self-update
composer global require "fxp/composer-asset-plugin:~1.1.1"
cd yii2-shop
composer install

GETTING STARTED

After you install the application, you have to conduct the following steps to initialize the installed application. You only need to do these once for all.

  1. Run command init to initialize the application with a specific environment.
  2. Create a new database and adjust the components['db'] configuration in common/config/main-local.php accordingly.
  3. Apply migrations with console command yii migrate. This will create tables needed for the application to work.
  4. Set document roots of your Web server:
  • for frontend /path/to/yii2shop/frontend/web/ and using the URL http://shop.local/
  • for backend /path/to/yii2shop/backend/web/ and using the URL http://admin.shop.local/

To login into the application, you need to first sign up, with any of your email address, username and password. Then, you can login into the application with same email address and password at any time.

yii2-shop's People

Contributors

mkrvevgn avatar monadona avatar mydesign avatar samdark avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yii2-shop's Issues

How can I install yii2-shop

In installation notes you have this commands:
composer global require "fxp/composer-asset-plugin:1.0.0"
composer install

This commands don't install yii2-shop, how can we install the template using composer?

Test Data

Anyone who have Data that can be inserted just to make a good demo.
SQL Script I mean with Data

$model on catalog/_product

where does $model come from?
can you explain to me please?
What techniques do you use ?
it suddenly appearing an instance object of Product.

thanks.

please update readme.md

I followed your instruction that not successful.

C:\xampp\htdocs>git clone [email protected]:samdark/yii2-shop.git myshop
Cloning into 'myshop'...
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Next I clone project instead.

=> git clone https://github.com/samdark/yii2-shop.git
OK

=>composer global require "fxp/composer-asset-plugin:~1.0.3"
OK

=> cd yii2 shop
=> composer install
OK

=> init
(Dev mode & edit db config)

=> yii migrate
OK database created.

enter browser => http://localhost/yii2shop/frontend/web/

Error show ....

Invalid Parameter – yii\base\InvalidParamException
The file or directory to be published does not exist: C:\xampp\htdocs\yii2shop/vendor\bower/jquery/dist

How can I create categories

I am logged in, and I'm in the back end. The first thing I do is click the Categories tab, and then I click the Create Category green button. The Parent dropdown list has just one choice: Root. In the title field, I enter "cat 1" without quotes. Then I click the Create button, and I get this error:

Bad Request (#400)
Unable to verify your data submission.
The above error occurred while the Web server was processing your request.
Please contact us if you think this is a server error. Thank you.

What am I doing wrong?

Goods of 3-rd (and deeper) level of categories will not be shown...

In case if goods must appear at third level of categories (and deeper)
it will be impossible to see goods (if they are exist).
For example, categories like this (uppercase) and goods like this (lowercase)
 - COMPUTERS
 - - APPLE
 - - - iPADS       (iPad1,iPad2,iPad3...)
 - - - iPHONES     (iPhone 16Gb, iPhone 32Gb, iPhone 64Gb)
 - - - MACBOOK PRO (MacBook 2013, MacBook 2014)
 - - - 
 - - IBM
 - - - SOFTWARE      (Software 1, Software 2)
 - - - HARDWARE      (IBM Server 1,IBM Server 2)
 - - ASUS    [good, that will be shown 1, good, that will be shown 2]
 - - ACER    [good, that will be shown 3, good, that will be shown 4]

 When you are at frontend, at "Catalog/list" route, if you click by "COMPUTERS" category link, 
 All this goods (in parentheses) will not appear at the list by right side.
 because this part of code (function getCategoryIds) will not (and never) executed:

 if (isset($categories[$categoryId]['items'])) {`
            foreach ($categories[$categoryId]['items'] as $subCategoryId => $subCategory)
            $this->getCategoryIds($categories, $subCategoryId, $categoryIds);
 }

 But, goods of first and second level of categories (in square brackets), 
 will be shown, because of this part of code:

       if ($category->id == $categoryId || $category->parent_id == $categoryId) {
            $categoryIds[] = $category->id;
        }

 The problem is: Recursion is not executed.
 What is "items"?, its look like not defined (actually, values by dimension [items])

My solution is change code of function "getCategoryIds" like this:

private function getCategoryIds($categories, $categoryId, &$categoryIds = [])
{
    foreach ($categories as $category) {
        if ($category->id == $categoryId) {
            $categoryIds[] = $category->id;
        }
    elseif ($category->parent_id == $categoryId){
            $this->getCategoryIds($categories, $category->id, $categoryIds);
        }
    }
    return $categoryIds;
}

Composer problem

Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.
Your requirements could not be resolved to an installable set of packages.

Problem 1
- Installation request for yiisoft/yii2-composer 2.0.3 -> satisfiable by yiisoft/yii2-composer[2.0.3].
- yiisoft/yii2-composer 2.0.3 requires composer-plugin-api 1.0.0 -> no matching package found.
Problem 2
- yiisoft/yii2-composer 2.0.3 requires composer-plugin-api 1.0.0 -> no matching package found.
- yiisoft/yii2 2.0.3 requires yiisoft/yii2-composer * -> satisfiable by yiisoft/yii2-composer[2.0.3].
- Installation request for yiisoft/yii2 2.0.3 -> satisfiable by yiisoft/yii2[2.0.3].

Potential causes:

Read https://getcomposer.org/doc/articles/troubleshooting.md for further common problems.

Should Use Environments To Setup Config

Hey, in my opinion, they should use the environments directory for setting up config settings. I am not sure exactly what changes you have compared to default Yii2 Advanced.

If they init first, then modify /common/config/main-local.php to include their db info, it will be overwritten next time they run init.

They should first modify /environments/dev/common/config/main-local.php and get it they way they want for development (db info, etc). Then run init. This way, they don't lose any of their settings.

Interface 'yz\shoppingcart\CartPositionInterface' not found

Hi! I am learning the YII2.And I am very glad to learn by your code.but when i run it,it throw a Fatal Error.
`PHP Fatal Error – yii\base\ErrorException

Interface 'yz\shoppingcart\CartPositionInterface' not found`

I found that no yz folder.How can i get it??Thanks

Installation problem

Try to install by yours manual and get error

Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for yiisoft/yii2-composer 2.0.3 -> satisfiable by yiisoft/yii2-composer[2.0.3].
    - yiisoft/yii2-composer 2.0.3 requires composer-plugin-api 1.0.0 -> no matching package found.
  Problem 2
    - yiisoft/yii2-composer 2.0.3 requires composer-plugin-api 1.0.0 -> no matching package found.
    - yiisoft/yii2 2.0.3 requires yiisoft/yii2-composer * -> satisfiable by yiisoft/yii2-composer[2.0.3].
    - Installation request for yiisoft/yii2 2.0.3 -> satisfiable by yiisoft/yii2[2.0.3].

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.

Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

"Permission denied" error message from github

When I run this:
git clone [email protected]:samdark/yii2-shop.git

I get the following message:
Cloning into 'yii2-shop'...
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

What am I doing wrong?

Thanks.

Problem installing script

Hello,

I am trying to install the package as the given instruction. But when I issue "Composer Install" I get the following errors. I am totally new to Yii and need help.
Error :
E:\xampp\htdocs\yii2-shop (master)
λ composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.

Problem 1
- Installation request for yiisoft/yii2-composer 2.0.3 -> satisfiable by yiisoft/yii2-composer[2.0.3].
- yiisoft/yii2-composer 2.0.3 requires composer-plugin-api 1.0.0 -> no matching package found.
Problem 2
- yiisoft/yii2-composer 2.0.3 requires composer-plugin-api 1.0.0 -> no matching package found.
- yiisoft/yii2 2.0.3 requires yiisoft/yii2-composer * -> satisfiable by yiisoft/yii2-composer[2.0.3].
- Installation request for yiisoft/yii2 2.0.3 -> satisfiable by yiisoft/yii2[2.0.3].

Potential causes:

Не хватает компонентов

Здравствуйте.

Занялся изучением yii2 и для примера изучаю как построен ваш мини-магазин, но при его установке возникло пару проблем возможно Вы поможете их решить:

  1. В описании есть папке вендоров в репозитории ее нету (закинул стандартную папку с эдвансета версии 2.0.9)
  2. Бекэнд запустился, а вот во фронтэнде пишет что нет таких путей:
    use yz\shoppingcart\CartPositionInterface;
    use yz\shoppingcart\CartPositionTrait;

Подскажите где достать недостающие файлы что бы приложение запустилось?

If the root category is added last, its value may not be displayed

CatalogController.php

 foreach ($categories as $category) {
      if ($category->parent_id === null) {
            $menuItems[$category->id] = [
             'active' => $activeId === $category->id,
             'label' => $category->title,
          'url' => ['catalog/list', 'id' => $category->id],
      ];
     } else {
         $this->placeCategory($category, $menuItems, $activeId);
     }
}

If the root category is added last, its value may not be displayed

yiisoft/yii2-codeception

yiisoft / yii2-codeception - is no longer relevant. It is registered in the dependencies samdark / yii2-shop

  I decided to try installing $ composer require dmstr / yii2-adminlte-asset "^ 2.1" in yi2-shop (samdark) and connect nested-sets and now the composer got out: 'Package yiisoft / yii2-codeception is abandoned, you should avoid using it. Use codeception / codeception instead '. in composer.json - "yiisoft / yii2-codeception": "*",

include database dump

Hi Sam,

Thank you for putting this together I think its good starting point for someone looking to build a store with yii2, although its not fully fleged but its something. I think it would be nice to include migrations for tables or a database dump just to get it up and running.

regards
alirz23

EAV

А нет ли похожего, только с атрибутами у товаров ? :)

return $this->redirect('catalog/list');

CartController.php
line 78,88

result

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

SluggableBehavior doesn't generate unique Slugs.

Hi,
I'm afraid the SluggableBehavior doesn't work as it should be.
I think SluggableBehavior job is to generate unique slugs, but here, i don't see unique slugs.
It generates slugs and insert them into DB, but if we have duplicate titles, it generates duplicate slugs.

ShoppingCart::getCount() Error

Hey, I just wanted to take a look at this shop beacause I'm learning yii2 at the moment, but I always get an error. No files edited though.

yz\shoppingcart\ShoppingCart::getCount(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "common\models\Article" of the object you are trying to operate on was loaded before unserialize() gets called or provide a __autoload() function to load the class definition

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.