theframework/helpers

库,帮助您使用面向对象的方式创建HTML元素

0.1.0 2018-02-25 18:39 UTC

This package is not auto-updated.

Last update: 2024-09-29 01:48:12 UTC


README

PHP视图辅助函数,用于使用对象渲染HTML元素

使用composer安装

    composer require theframework/helpers

假设您有一个根文件夹 "myphpsite",其中包含一个 index.php 文件

    PCALEX@MSI MINGW64 /d/temp/myphpsite

    $ composer require theframework/helpers

    Using version ^0.0.2 for theframework/helpers
    ./composer.json has been created
    Loading composer repositories with package information
    Updating dependencies (including require-dev)
    Package operations: 1 install, 0 updates, 0 removals
      - Installing theframework/helpers (0.0.2): Loading from cache
    Writing lock file
    Generating autoload files

    PCALEX@MSI MINGW64 /d/temp/myphpsite

使用composer安装后,将创建以下结构

    myphpsite/
        vendor/
            composer/
            theframework/
                helpers/
                    autoload.php
                    ...
            autoload.php
        composer.json
        composer.lock

        index.php  --> your index file

包含autoload.php

autoload.php文件使您可以使用命名空间路径(在这种情况下,使用 use 操作符)而不是使用 requireincluderequire_onceinclude_once 操作符来实例化类(在这种情况下,辅助函数)

<?php
//this is index.php  path: myphpsite/index.php
//notice that including autoload.php path using composer is not the same as downloading the package. 

include_once("vendors/autoload.php");//if installed with composer
//or
include_once("theframework/helpers/autoload.php");//if downloaded from http://helpers.theframework.es/versions/
//or
include_once("<anyfolder-you-create>/autoload.php");//downloaded from https://github.com/eacevedof/prj_theframework_helpers/releases

use TheFramework\Helpers\HelperInputText;
$oInput = new HelperInputText();
$oInput->set_name("txtMiFirstInput");
$oInput->set_value("Hello World");
$oInput->add_class("form-control");
$oInput->is_readonly();
$oInput->required();
$oInput->set_maxlength(35);
$oInput->show();