Download the PHP package mikehaertl/xcrudcontroller without Composer

On this page you can find all versions of the php package mikehaertl/xcrudcontroller. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package xcrudcontroller

XCrudController

A base class to quickly build customized CRUD interfaces.

Features

Quickstart

1 A simple controller

To get started you only have to supply the name of the ActiveRecord class that you want to build a CRUD for:

2 Create view files

You have to supply the list, edit and detail views.

Note: The markup is very reduced. In a real life project you'd of course style these elements apropriately. You could also start from the CRUD templates as generated from Gii. But you have to rearrange and modify them a little.

2.1 List view

The list view contains the filter form and renders the partial view for the actual items via _items.

protected/views/user/list.php:

Note: In real life your filter form is usually offering way more search options. You would better implement this through a dedicated filter form. See below for details.

protected/views/user/_items.php:

Notice how the links to view and edit an item are built through createItemUrl(). This adds the current list page URL as URL parameter so that it's very easy to link back to this search result page.

2.2 Create/edit form

protected/views/user/form.php:

Note: The form name must be strtolower($this->modelName).'-form' if you want to use AJAX validation with CActiveForm.

2.3 Detail view

protected/views/user/form.php:

Configuration

Views

As you've seen above, 4 view files must be provided for the controller:

The view names can be configured in $listView, $listPartial, $formView and $detailView properties.

The views use a pull mechanism to fetch their data:

After a record was created or updated a flash message with the key $modelName-created or $modelName-updated is set respectively. You can use this to show a success message in the view which you show after saving a record.

Note: You can control, which page you want to show after you created a new record. By default this will be the list page (with filters reset). You can also show the detail view of the new record or stay on the edit page, if you want. Therefore you have to create the "Add" link like this:

CHtml::link('Add user', array('edit', $this->returnVar=>'view'));

Instead of 'view' you can also use 'edit' to redirect to the edit form of the newly created record.

Scenarios

You can configure several scenarios which are set on the $model or $filterModel for specific actions:

Other options

If you don't want to provide all actions, you can disable some of them through $crudActions. By default this is `array('edit', 'list', 'view', 'delete').

The name of the URL parameter for the return URL is set through $returnVar and defaults to returnUrl.

Advanced tricks

Using a filter model

In the simplest case a filter model is an ActiveRecord as created by Gii. But if you want to keep your code cleaner, i'd recommend to use a separate model file for all your filter concerns. This has the advantage that you don't clutter up your ActiveRecords with search related code anymore and can focus on the search logic here:

In the controller you have to configure this model in $filterModelName:

How to get nicer URLs for your search results

The URL parameters to a search result page look like this:

...&User[username]=test&User[email][email protected]

This does not look very nice. It would be much better to have easier to read search parameters, just like Google or other search engines do it:

...&username=test&[email protected]

It's very easy to achieve this. You have to override the assignFilterModelAttributes() method in your controller like this:

It is safe to do this in this case: We only have the search form parameters in $_GET, plus maybe the pagination and sorting options. But as long as they don't interfere with your search model attributes everything is still fine.

But you also have to change the filter form a little because by default Yii will create form element names like User[username] whereas we want them to be only username now:


All versions of xcrudcontroller with dependencies

PHP Build Version
Package Version
Requires php Version >=5.0.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mikehaertl/xcrudcontroller contains the following files

Loading the files please wait ....