Download the PHP package marcogmonteiro/ci-admin-controller without Composer

On this page you can find all versions of the php package marcogmonteiro/ci-admin-controller. 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 ci-admin-controller

codeigniter 4 base controller

GitHub version

codeigniter-base-controller is an extended BaseController class to use in your CodeIgniter applications. Any controllers that inherit from BaseController or AdminController get intelligent view autoloading and layout support. It's strongly driven by the ideals of convention over configuration, favouring simplicity and consistency over configuration and complexity.

Synopsis a controller that extends to adminController

</div>

<p>Footer</p>

If you wish to disable the layout entirely and only display the view - a technique especially useful for AJAX requests - you can set $this->layout to FALSE.

$this->layout = FALSE;

Like with $this->view, $this->layout can also be used to specify an unconventional layout file:

$this->layout = 'layouts/mobile.php';

Any variables set in $this->data will be passed through to both the view and the layout files.

View structure

Your views should be created to support the built in functionality of layouts that comes with codeigniter 4

    <h1>Hello World from the home/index view!</h1>

As for your layouts, those should have a render section called yield.

<!doctype html>
<html>
<head>
    <title>My Layout</title>
</head>
<body>
    This is my layout content

</body>
</html>

To actually be able to rendere a view directly without the layout we need an empty layout doing the render. For that there's a nolayout.php file included in your Views/layouts folder that only does the view render.

The complete folder structure is now included in the project.

Loading Helpers in your controllers

If you want to load helpers in your controllers in a global scope and not inside a function all your have to do is declare the helpers property as array with all your helpers, like so:

<?php namespace App\Controllers;

class Home extends AdminController
{
    protected $helpers = ['url'];

    public function index()
    {
    }

}

AdminController CRUD

There's a few functions that you can use in your adminController that are not avaiable in your baseController. To do that some rules must be followed. First you need to load the main model your controller will be working with. Let's say you have a Articles controller and a ArticleModel first you load your model.

$this->article = model('App\Models\ArticleModel');

As you can see I'm loading the model into a class property called article. In this case my _$modelclass property should also be called article.

$this->model_class = 'article';

This way if your Article controller needs access to a update functionallity all you need to do is create a update function like so:

public function update($id)
{
    return $this->adminUpdate($id, $this->request->getPost());
}

This update function should always return the update result that was set on your adminController function.

In case you want to send the admin_update method something else other than your post data you can do it just like this:

public function update($id)
{
    $data = $this->request->getPost();
    $data['my_new_field'] = 'foobar';
    return $this->adminUpdate($id, $this->request->getPost());
}

This is specially usefull if you want to add some extra data that was not given by the post.

By default the success action of this function will always redirect to your index function in your controller. Using this structure always assume that you have a index function.

This redirect will also set a confirm flashdata automatically that can be used in your views.

In case you need to override this behavior that can be done by returning a diferent result.

public function update($id)
{
    $this->adminUpdate($id, $this->request->getPost());
    return [
        'url' => '/admin/list_articles',
        'success' => 'Your article was updated.'
    ];
}

This way you're redirecting the user to your /admin/list_articles with the flashdata "your article was updated.".

Use AdminController in root directory

In case you want to use AdminController in root directory, or any other directory change the $directory property.

protected $directory = ''; // Set default directory

Add your own language variables

The CRUD methods now support the use of language variables. Those should be se in your app/languages folder depending on your locales settings. For now the following languages are supported:

Error Helper

In your adminController.php there's a custom helper being loaded called error helper. That should be placed in your helpers folder and it's only purpose is to serve as a shortcut for the 404 exception.

// This is just the same thing
show_404();
// as
throw \CodeIgniter\Exceptions\PageNotFoundException::forPageNotFound();

You can now use this on your controllers too everytime you need to show a 404 error. Since its autoloaded on your adminController.

Roadmap

Codeigniter 3 version, no CRUD controller, only autoload views

If you're still using codeigniter 3 and want something like this that can be found here: jamierumbelow/codeigniter-base-controller


All versions of ci-admin-controller with dependencies

PHP Build Version
Package Version
No informations.
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 marcogmonteiro/ci-admin-controller contains the following files

Loading the files please wait ....