Git Product home page Git Product logo

crudlex's Introduction

CRUDlex

CRUDlex is an easy to use, well documented and tested CRUD generator for Symfony 4 and Silex 2. It is very useful to generate admin pages for example.

Support via Gratipay

List View of CRUDlex

Features

  • Generates a web application for managing MySQL stored data
    • C reate entries
    • R ead entries in a list and the details of single ones
    • U pdate entries
    • D elete entries
  • The list of entries is paginated, sortable and filterable
  • The entries can be relational, one-to-many and many-to-many is supported
  • Managing files is supported, either stored in the filesystem or at AWS S3 as addon
  • The UI is available in multiple languages
  • File storage is abstract, implementing other systems than the filesystem and AWS S3 is easy
  • Data storage is abstract, implementing other backends than MySQL is easy

Total Downloads Latest Stable Version Latest Unstable Version License

Build Status Code Coverage

SensioLabsInsight Scrutinizer Code Quality

Usage

As CRUDlex is framework agnostic, it is not used directly. There are framework specific implementations available:

Head over to the documentation for setup instructions.

CRUDlex uses SemVer for versioning. Currently, the API changes quickly due to be < 1.0.0, so take care about notes in the changelog when upgrading.

Documentation

Upcoming development version:

Sample Project

For a complete example, checkout the sample project with the classic libraries and books:

Addons

There are several surrounding projects around CRUDlex:

  • CRUDlexUser: A library offering an user provider for symfony/security

Roadmap

The project roadmap is organized via milestones:

CRUDlex Milestones

Beware that not each new feature will get its own ticket there. Some are implemented on the fly when needed.

Each milestone is loosely organized as project in the columns "Backlog" (Todo), "Staging" (Being worked on (next)) and "Done" (done):

CRUDlex Milestone Projects

Older Versions Documentation

Manual

The manual is a reference describing every feature of CRUDlex:

API Documentation

The CRUDlex API itself is documented here:

Build Notes

How to generate the API documentation:

vendor/bin/sphpdox process CRUDlex src  

How to build the documentation:

# Install dependencies
pip install Sphinx
pip install tk.phpautodoc
pip install sphinx_tabs
# Generate:
cd docs
make html

crudlex's People

Contributors

dmaciel avatar jchiotaka avatar philiplb avatar prodigitalson avatar timfreiheit 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

crudlex's Issues

fatal error due to changed arguments

api: listEntries( array $filter = array(), integer $skip = null, integer $amount = null )
called with: array, null, 1
to get only the first result

Catchable fatal error: Argument 2 passed to CRUDlex\CRUDMySQLData::listEntries() must be of the type array, integer given, called in ...\index.php on line 293 and defined in ...\app\vendor\philiplb\crudlex\src\CRUDlex\CRUDMySQLData.php on line 107

404 in manual

"in deiner documentation führt der "Next: Constraints" link von der Seite "Data Types" zu einem 404er
das gilt für alle "next" ab data types"

M:N relationships

  • basic implementation
    • design YML fields and extend the EntityDefinition with them
    • render
    • create, UI having a basic implementation with a multiselect
    • update: same as on creation, but delete existing relationship entries upfront
  • [Fri Sep 09 22:25:51.330299 2016] [:error] [pid 2714] [client ::1:50576] PHP Notice: Undefined index: isOpenOnSundays in /Users/philiplb/Sites/CRUDlex/src/CRUDlex/AbstractData.php on line 79, referer: http://localhost/~philiplb/CRUDlexSample/web/crud/library/create
  • [Sat Sep 10 08:39:11.836594 2016] [:error] [pid 26079] [client ::1:52711] PHP Warning: Invalid argument supplied for foreach() in /Users/philiplb/Sites/CRUDlex/src/CRUDlex/MySQLData.php on line 318, referer: http://localhost/~philiplb/CRUDlexSample/web/crud/library/create
  • adding a validator
  • extended UI with one of
  • care about constraints
    • required
    • unique
  • don't allow to sort by a many field on the list view, to be mentioned in the docs
  • filter
  • unit tests
  • docs
    • write missing API docs
    • data type with sample
    • mention the missing sorting option
    • regenerate docs

Broken events

Well, broken or I don't know how to use them.
Test from a fresh project sample both in v0.9.9 and v0.9.x-dev, I added this on line 38:

New syntax:

$app['crud']->getData('library')->pushEvent('before', 'create', function(Entity $entity) {
    // Do something with the entity which is about to be saved.
    return true;
});

Generates:

Catchable fatal error: Argument 1 passed to {closure}() must be an instance of Entity, instance of CRUDlex\Entity given, called in /CRUDlexSample-master/vendor/philiplb/crudlex/src/CRUDlex/Data.php on line 104 and defined in //CRUDlexSample-master/web/index.php on line 39

Old syntax:

$app['crud']->getData('library')->pushEvent('before', 'create', function(CRUDEntity $entity) {
    // Do something with the entity which is about to be saved.
    return true;
});

Generates:

Catchable fatal error: Argument 1 passed to {closure}() must be an instance of CRUDEntity, instance of CRUDlex\Entity given, called in //CRUDlexSample-master/vendor/philiplb/crudlex/src/CRUDlex/Data.php on line 104 and defined in /CRUDlexSample-master/web/index.php on line 40

pushEvents + database access

This is somehow related to Issue #44.

I would also like to fill a field in the database from inside a pushEvents.

I have made some tests in a separate controller and succeeded to access the database by invoking $data = $app['crud']->getData($entity); and then using CRUDlex's setters.

However when trying to do it from inside my pushEvents function, I can't access the $app object. Is there any recommended way to to use the API's functions inside a pushEvents callback?

Sample code tryings and error:

$xls2json = function(CRUDlex\CRUDEntity $entity) {
    global $app;
    $data = $app['crud']->getData($entity);
...
$app['crud']->getData('imports')->pushEvent('after', 'create', $xls2json);

or

$xls2json = function(CRUDlex\CRUDEntity $entity) use ($app) {
    $data = $app['crud']->getData($entity);
...
$app['crud']->getData('imports')->pushEvent('after', 'create', $xls2json);

both lead to:

ContextErrorException in CRUDServiceProvider.php line 289:
Warning: array_key_exists(): The first argument should be either a string or an integer

Missing API doc: using CRUDlex in custom controllers

Hi,
My CRUDlex app is setup, and I would like to be able to read/write outside CRUDlex (in my custom controllers).

I can't understand how to use the API for that.
I can retrieve the definition: $app['crud']->getData('player')->getDefinition();
The MYSQLdata object: $app['crud']->getData('player')

But I can't figure out how to initiate an Entity so that I can perform ->set and ->create operations.

Any tips about that would be appreciated!

i want exteds library code

hi, i want change my post values before saving. For example. user post "3.14" i want just "3"
explode('.', $_GET['blabla']);

my other question.i use image data type. it is work. but it not showing as image. it showing as text.
i want see image on list table.

my english is bad, sorry.

[Feature Request] Additional CSS Identifiers for Default Templates

Why?

For most of my intended usage, any changes to the look and feel of the default templates can be accomplished via CSS. However, there are cases where there are no identifiers that can be used to differentiate between an entity's list table or an entity's show table, for example. Adding a few would make using custom CSS much simpler. While using custom templates is possible, it would result in a lot of code duplication just to change a single line.

Proposed Template Class/ID Additions

  1. Adding a crudEntityListTable class to the primary table in list.twig
  2. Adding class crudEntityShowTable to the primary table in show.twig
  3. Adding class crudEntityChildListTable to the child table in show.twig
  4. Adding ID crudChild{{ childEntity.get(child[0]) }} to the child table in show.twig

While We're at it...

When working with the standard CRUD application UI, I frequently alter the width of columns to make things look a bit cleaner. Currently, this can only be accomplished by using an nth-child CSS selector, which breaks if you change the order of the columns. Instead, adding an ID for each column based on the field name would make this a bit easier (in list.twig):

    {% for field in fields %}
        <th id="crudEntityField{{ field }}">
        (snip)
        </th>
    {% endfor %}
    <th id="crudA">Action</th>

But I would consider this less important.

I'm not attached to any of the specific names, I just tried to pick names that were consistent with your other classes. Also happy to submit a PR with said changes as well.

Improvement request: use proper Twig truncate() filter inside templates

E.g.:

{{ basename|truncate(30) }}

outputs the 30 first characters and adds '...' (default separator) only if the string is longer than that.

More relevant than the hard-coded:

{{ basename|slice(0, 30) }}...

I'll do it myself as soon as I finish my current project (~2 weeks) and read carefully how to contribute an existing project.

Mechanism to define the fields of the list view

Maybe: New key for field "hideFromList" in order to not let a field appear in the listview table
Or: optional "listFields" attribute in the entity in order to manage also the default fields like the id, defaults to all fields like it is now

Add more flexibility to template

Hi @philiplb,

I'm trying your projet in professionnal context. What do you think to enhance templating with these functionalities :

  • Provide a tab system directly in crud yaml definition
  • Provide the possibility to add some extra css class directly in crud yaml definition
  • A very functional feature : duplicate fields or duplicate group field
  • Add the possibility to embed form in form. Ex : A person profile as a part experience. It's helpful to add experience form directly in the "base" form (and add the possibility to add more one experience)

For me, overriding every template is a bad idea ...

A better solution is the possibility to override easily the EntityDefinition class.

Actually, if I want to override the EntityDefinition to add some extra functionalities, I need to extends the CRUDlex Service Provider, MySQLDataFactory and his interface etc... because there is an object type hinting in methods of class.

A very good exemple to illustrate my purposes, is the Django Admin from Python World and his module Django Suit http://djangosuit.com/

What do you think about these functionality ? There is no equivalent to Symfony/Silex community in front of Django community

Sorting on List View

Done

  • Sorting API
  • Sorting data in EntityDefinition
  • Optional sorting fields in the crud.yml
  • Controller
  • UI
  • Documentation

Todo

0.9.9 broken with silex/web-profiler ^1.0

First of all your congratulations for putting up CRUDlex!

CRUDlexSample deploys v.0.9.7 of ou the box.
Adding Web Profiler works well also:

    "require": {
        "philiplb/crudlex": "0.9.7",
        "silex/web-profiler": "^1.0"
    }

Unfortunately upgrading to v0.9.9 conflicts with the Web Profiler:

Twig_Error_Syntax in ExpressionParser.php line 604:
Unknown "trans" filter in "@crud/list.twig" at line 22.

Downgrade to v0.9.8:

Twig_Error_Syntax in ExpressionParser.php line 604:
Unknown "trans" filter in "@crud/list.twig" at line 14.

Removing silex/web-profiler (v1.0.8) restores CRUDlex v0.9.8 - v0.9.9

Any hints?

pushEvent after create + file upload

Hi,
when working with pushEvents I am trying to process a file automatically after upload.

I'm using an after create event, but it seems that it is fired before the file is actually uploaded (not present on the disk).

The following code sample always returns $file = false:

$xls2json = function(CRUDlex\CRUDEntity $entity) {

    $filename   = $entity->get('filename');

    $fileid     = $entity->get('id');
    $path       = dirname(__DIR__).'/www/uploads/imports'; // any way to get it from the .yml?
    $filepath   = $path.'/'.$fileid.'/'.$filename;

    $file       = file_exists($filepath) ? $filepath : false;

    var_dump($file);
    exit();
    return true;
};
$app['crud']->getData('imports')->pushEvent('after', 'create', $xls2json);

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.