Download the PHP package codekanzlei/cake-cktools without Composer

On this page you can find all versions of the php package codekanzlei/cake-cktools. 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 cake-cktools

CakePHP 3 cake-cktools

Build Status

Requirements

Installation

1. require the plugin

$ composer install codekanzlei/cake-cktools

Open a terminal in your project-folder and run these commands:

$ composer update

3. Setup Appcontroller.php

$helpers

Usage

1. CkToolsHelper

Being one of CkTools' core features, CkToolsHelper provides many useful functionalities, most of them aimed at generating powerful view elements such as form- and navigation buttons, often with as much as one line of code. Here's an overview of its actions. See CkToolsHelper.php for further details.

@return string

2. MenuHelper

The MenuHelper aims at config-based rendering of hierarchical navigation menus in the UI. Here's an overview of its actions. See MenuHelper.php for further details.

config.php - a closer look

Here's an example of what config.php could look like, explaining more possibilities:

Create a PDF using CakePHP Views

CkTools includes a simple wrapper for the MPDF library. For detailed instructions on how to use it, see the github repository here: https://github.com/mpdf/mpdf

Usage

Here's an example use in a Cake Controller but you can use this feature wherever you want. See /cake-cktools/src/Lib/PdfGenerator.php for a closer look at the functionalities used.

In your Cake View file you can use the passed viewVars and the $mpdf variable for manipulating the PDF.

Sort table fields with SortableBehavior

CkTools provides a behavior that allows manipulation of the (displayed) order of the records of a table. If you change the position of one field, the behavior will automatically change all the other fields' positions accordingly. To manipulate the positions you can use an ordinary form field or for example the Cake Frontend Bridge to enable JavaScript-based drag-and-drop interaction in the browser UI.

Strict Passwords with StrictPasswordBehavior

Activate the strict password requirements by setting the StrictPasswordBehavior in UsersTable; default Configuration is set in this example

$this->addBehavior('CkTools.StrictPassword', [ // minimal password length 'minPasswordLength' => 10, // fistname and surname are not allowed in password (case insensitive) 'noUserName' => true, // at least one special char is needed in password 'specialChars' => true, // at least one char in upper case is needed in password 'upperCase' => true, // at least one char in lower case is needed in password 'lowerCase' => true, // at least one numeric value is needed in password 'numericValue' => true, // reuse of old passwords is not allowed: number of old passwords to preserve 'oldPasswordCount' => 4 ]);

Usage

Add the SortableBehavior to the Table you want to use it in:

The current 'position' of the record will be stored as an integer in the field 'sort'. You need to have this field in your Model. If it's not called 'sort', you can configure the behavior accordingly here.

Here's what the table field you wish to allow sorting by could look like in CakePHP schema.

Manipulate database records with TableUtilitiesTrait

The TableUtilitiesTrait contains an action that allows for manually updating the value of a field in a table. Using updateField() bypasses cake validation and patching of the object. The given value is directly written to the database via a SQL query.

Setting up a Model

Add the Trait in YourTable.php:

Now you can use the updateField() action to directly manipulate a record. Let's take a closer look at its parameters:

Handle type constants with TypeAwareTrait

Entities with type constants can be very useful, for example if you wish to grant different rights to different kinds of users such as Admins, regular Users, External users etc. With CkTools' TypeAwareTrait, setting up and using such constants becomes fast and simple.

Setting up a Model:

Let's prepare an example use case where you want to assign different roles to different groups of users in your application. Set up your User.php like so:

Let's stick with the User roles example. Here's how you can access your type constants:

Using this Trait allows for simple control over which actions the currently logged in user can and cannot access. You can use your own methods for granting/denying access to Controller actions or simply use the TypeAwareTrait to prevent action buttons from being rendered in the UI.

Example: in a Cake View file for Model Cars:

Identify users with UserToken

CkTools provides a utility class that generates serialized, encrypted and base64-encoded for identifying users, usually for usage in an URL. This is very handy for 'forgot password' links so if you have a LoginController, using UserToken there is most advisable.

Usage

Here's how to use UserToken in any class you like:

Now you can access the following actions via the $UserToken object:

See cake-cktools/src/Utility/UserToken.php for further information about these actions.

InternationalizationShell

CkTools provides a helper shell for i18n related tasks.

Update .po and .mo files from catalog

To automate the updating of .po/.mo files from available translation strings from the catalog (.pot) file, use the updateFromCatalog command.

This is done using the excellent oscarotero/Gettext library.

Usage

  1. Update all default.po and default.mo files found in src/Locale/* with translation strings from src/Locale/default.pot. The shell will list the files it will touch and asks for confirmation.

    bin/cake CkTools.Internationalization updateFromCatalog
  2. Update all default.po and default.mo files found in src/Locale/* with translation strings from src/Locale/default.pot. The shell will overwrite files without interaction.

    bin/cake CkTools.Internationalization updateFromCatalog --overwrite
  3. Update all default.po and default.mo files found in src/Locale/* with translation strings from src/Locale/default.pot. The shell will overwrite files without interaction. Also, it will strip all references, meaning the filenames and lines where the translation was used from the resulting .po and .mo files.

    bin/cake CkTools.Internationalization updateFromCatalog --overwrite --strip-references
  4. Update all cake.po and cake.mo files found in src/Locale/* with translation strings from src/Locale/default.pot. The shell will list the files it will touch and asks for confirmation.

    bin/cake CkTools.Internationalization updateFromCatalog --domain cake

PasswordHasher Shell

In case you need to renew a password in your local dev db, use this shell to genreate a hash.

    bin/cake CkTools.PasswordHasher <password-to-hash>

SecurityComponent

CkTools provides a component to set multiple security enhancing headers.

Security headers

Loading the SecurityComponent in your AppController, the Component will hook into the beforeFilter event and by default set the

At the moment these two headers are neither configurable nor can you deactivate them, as they seem to be reasonable in every case.

Furthermore, you can configure multiple additional headers in your app.php.

Usage

Here is how a complete configuration of all additional security headers could look like in your app.php:

The X-Frame-Options header set by 'denyFraming' is superceded by the Content Security Policy's frame-ancestors directive, but as frame-ancestors is not yet supported in IE11 and older, Edge, Safari 9.1 (desktop), and Safari 9.2 (iOS), it is recommended that sites employ X-Frame-Options in addition to using CSP.

If you wish to exclude any header, simply set its value to something falsy or omit the array key completely.


All versions of cake-cktools with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
cakephp/cakephp Version ~3.6
mpdf/mpdf Version ^7.0
gettext/gettext Version ^4.1
scherersoftware/cake-api-baselayer Version ^2.0
codekanzlei/cake-frontend-bridge Version 3.0.*
codekanzlei/cake-auth-actions Version 3.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 codekanzlei/cake-cktools contains the following files

Loading the files please wait ....