GithubHelp home page GithubHelp logo

akrabat / slim3-bookshelf Goto Github PK

View Code? Open in Web Editor NEW
122.0 15.0 20.0 420 KB

Exploratory Slim Framework 3 application.

License: BSD 3-Clause "New" or "Revised" License

CSS 1.01% PHP 65.38% JavaScript 4.20% Twig 29.41%

slim3-bookshelf's Introduction

Slim Bookshelf

This is a simple Slim 3 application that manages a list of books

It uses :

  • Slim 3
  • Illuminate as its database ORM
  • Twig

Composer

This project uses Composer. Run composer install to install the dependencies.

Run with php built-in web server

  1. cd public && php -s localhost:8888 index.php
  2. navigate to http://localhost:8888

Vagrant

To use the Vagrant VM, install Vagrant, Virtual Box & the VirtualBox Extension Pack.

  1. vagrant up
  2. navigate to http://localhost:8888

Cloud Foundry

You can deploy this app to Cloud Foundry with cf push. Look in manifest.yml and .bp-config/options.json for configuration.

SQLite

To use SQLite as a database:

  • create database
sqlite
.read data/seed-sqlite.sql
.save data/database.sqlite
  • copy app/settings.php.dist to app/settings.php
  • replace the database section
'db' => [
    // Illuminate/database configuration
    'driver'    => 'sqlite',
    'database'  => 'data/database.sqlite',
    'charset'   => 'utf8',
    'collation' => 'utf8_unicode_ci',
    'prefix'    => '',
],

Credits

The favicon is from the open source project Twemoji. The graphics are copyright 2020 Twitter, Inc and other contributors. The graphics are licensed under CC-BY 4.0.

slim3-bookshelf's People

Contributors

8ctopus avatar akrabat avatar permanar 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

slim3-bookshelf's Issues

Using PDO instad of Eloquent?

Im trying to remove Eloquent from your app, and instead using PDO

But I´m having a hard time figuring out how the Model would look like, to initiate the PDO instance from the model.

<?php
namespace Bookshelf;
use PDO
final class Book
{
    protected $db;

    public function __construct(PDO $db)
    {
        $this->db = $db;
    }

    public static function find($id)
    {
        $sql = "SELECT * FROM books WHERE id = :id";
        $query = $db->prepare($sql);
        $query->execute(array(':id' => $id));

        return $query->fetchAll();
    }
}

How would can this be done?
Thanks in advance!

Seems not to work for me at all...

Php version 5.5.6.
I'm keep seeing white screen of death without errors from start.
When registering error handler, I've got:

Type: LogicException
Message: Cache can only be a string, false, or a Twig_CacheInterface implementation.
File: \vendor\twig\twig\lib\Twig\Environment.php
Line: 269

first, when changed cache to "false" instead of null:

Type: InvalidArgumentException
Message: Database [default] not configured.
File:\vendor\illuminate\database\DatabaseManager.php
Line: 246

What's wrong?
Of course everything is set, settings file parsed ok, DB exists and login details are correct.

cd: /vagrant/vm-provisioning: No such file or directory

Hi.

I'm trying to run this app but "sudo vagrant up" is failing at the last hurdle...

default: Running: inline script

==> default: /tmp/vagrant-shell: line 1: cd: /vagrant/vm-provisioning: No such file or directory

Any pointers as to how to sort this would be much appreciated.

Thanks,

Dan

save() throws internal server error

When I try to save model, I get internal server error, and can't catch error at all. My model have only two columns, id pk autoincrement and name (string 255) this is my settup:

Model:

class Version extends Illuminate\Database\Eloquent\Model
{
    protected $table = 'version';

    protected $fillable = ['name'];

    protected $hidden = ['id'];
}

Action:

public function create(RequestInterface $request, ResponseInterface $response)
    {
        $params = $request->getParsedBody();
        $class = $this->model; // App\Models\Version
        $model = new $class();
        $model->fill($params);

        return $model->save() ?
            $this->success($response, "{$this->getModelName()} successfully saved.") :
            $this->error($response, $model->errors());

    }

I manager to localize issue, by adding break points, to this part of code in Illuminate\Database\Eloquent\Builder line #1242

if (in_array($method, $this->passthru)) {
            return call_user_func_array([$this->toBase(), $method], $parameters);
        }

But I have no idea what is wrong

slim 4 upgrade

Rob, I'm planning to upgrade your project to slim 4, are you interested in a pull request for that or you prefer to keep it under slim 3?

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.