承接 moonwalkingbits/wordpress-autoloader 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

moonwalkingbits/wordpress-autoloader

Composer 安装命令:

composer require moonwalkingbits/wordpress-autoloader

包简介

A class loader for the WordPress coding standards.

README 文档

README

A class loader for the WordPress coding standards.

When taking the object oriented approach to developing in PHP, autoloading can get rid of all the include/require statements in your code. Instead of manually including the file before you use the class, or having to check if the class is available you just use it. If it is not yet included it will be automatically included by the class loader.

The only class file you need to include is the autoloader. Or if you use this library as a composer package it is enough to include composer's autoload.php. After you've set it up it will take care of the rest of the includes.

<?php

require_once '/path/to/class-autoloader.php';

$autoloader = new Moonwalking_Bits\Autoloader();

// Add as many namespace mappings as needed.
$autoloader->add_namespace_mapping( 'Namespace', '/path/to/classes' );

// Register the autoloader with the spl provided autoload queue.
spl_autoload_register( array( $autoloader, 'load_class' ) );

After this setup any class in the Namespace namespace that resides in the registered namespace directory can be used directly without any include/require statements.

Nested namespaces

The autoloader will resolve any classes with nested namespace as long as the directory structure follows the namespace path:

<?php

$autoloader->add_namespace_mapping( 'Namespace', '/path/to/classes' );
<?php // /path/to/classes/nested/class-test-class.php

namespace Namespace\Nested;

class Test_Class {}

Given the above example the class Namespace\Nested\Test_Class will be loaded correctly.

Classes without namespace

To load classes that do not use any namespace just register the mapping with an empty namespace:

<?php

$autoloader->add_namespace_mapping( '', '/path/to/classes' );

License

Autoloader is released under the GPL license.

统计信息

  • 总下载量: 366
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2020-06-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固