GithubHelp home page GithubHelp logo

kuronekowen / marketplace Goto Github PK

View Code? Open in Web Editor NEW

This project forked from knplabs/marketplace

0.0 2.0 0.0 319 KB

The Marketplace is where KNP ninjas share ideas, projects and stuff. THIS PROJECT IS MAINTAINED BY ubermuda

Home Page: http://knplabs.com/blog/csi/opensourcing-the-knplabs-marketplace

PHP 71.25% HTML 25.88% ApacheConf 0.27% CSS 1.38% JavaScript 1.21%

marketplace's Introduction

Idea Marketplace

Intro

The Marketplace is where KNP ninjas share ideas, projects and stuff. It's built on top of Silex.

configuration

Setting up the marketplace is a simple 3-step process:

# install vendors
bin/vendors install
# create and customize your config.php
cp app/config.php.dist app/config.php
# make sure the cache folder is writable
chmod 777 cache

And you're set!

Note: since the SQL schema migrations take place during the before hook, a simple hit on the application will initiate it.

About the Marketplace

Vendors

The Marketplace uses a patched version of Symfony2's bin/vendors. Not much to say here, except it makes life easier.

Authentification

The Marketplace uses Google OpenID for identification, and a custom, dead simple, homebrew authentication system consisting in a simple pimple service, which return value determines whether you can access the app (true) or not (false). On the KnpLabs instance of the Marketplace, this service's definition looks like that:

$app['auth']  = $app->share(function() use ($app) {
    return function($username) use ($app) {
        return (bool) preg_match('/@knplabs\.com$/', $username);
    };
});

Like I said, dead-simple.

Markdown

The Marketplace uses the SilexDiscountServiceProvider to provide markdown support. This service provider requires that you set the markdown.discount.bin parameter in your configuration file.

Twig extension

There is a Marketplace Twig extension in src/Marketplace/Twig to provide a few specific filters and gravatar support.

Project categories

Project categories are stored as a pimple parameter, project.categories, in src/config.php. See src/config.php.dist for an example.

Data repositories

Even though we don't use an ORM in the Marketplace, this is no reason to put your SQL en vrac inside your controllers. That is why we implemented a very simple way to store data retrieveing logic, in the form of repository classes, that you will find in src/Repository. Since we try to avoid magic as much as possible, those repositories need to be declared to the RepositoryServiceProvider, inside the bootstrap (src/bootstrap.php).

Migrations

The Marketplace features a simple homebrew schema migration system. Since there is no CLI system in Silex, everything takes place during the before filter. A migration consist of a single file, holding a migration class. By design, the migration file must be named something like <version>_<migration_name>Migration.php and located in src/Resources/migrations, and the class <migration_name>Migration. For example, if your migration adds a bar field to the foo table, and is the 5th migration of your schema, you should name your file 05_FooBarMigration.php, and the class would be named FooBarMigration.

In addition to these naming conventions, your migration class must extends Marketplace\AbstractMigration, which provides a few helping method such as getVersion and default implementations for migration methods.

The migration methods consist of 4 methods:

  • schemaUp
  • schemaDown
  • appUp
  • appDown

The names are pretty self-explanatory. Each schema* method is fed a Doctrine\DBAL\Schema\Schema instance of which you're expected to work to add, remove or modify fields and/or tables. The app* method are given a Silex\Application instance, actually your very application. You can see an example of useful appUp migration in the CommentMarkdownCacheMigration.

There's one last method you should know about: getMigrationInfo. This method should return a self-explanatory description of the migration (it is optional though, and you can skip its implementation).

marketplace's People

Contributors

cameroncox avatar igorw avatar j0k3r avatar l3pp4rd avatar memphys avatar nucleartux avatar qpleple avatar stloyd avatar stof avatar ubermuda avatar willdurand avatar

Watchers

 avatar  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.