Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/emacle/hello-composer
first composer package
https://github.com/emacle/hello-composer
Last synced: 24 days ago
JSON representation
first composer package
- Host: GitHub
- URL: https://github.com/emacle/hello-composer
- Owner: emacle
- Created: 2020-05-09T07:23:56.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-01-18T11:34:27.000Z (about 2 years ago)
- Last Synced: 2024-11-08T04:17:11.184Z (3 months ago)
- Language: PHP
- Size: 4.88 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# hello-composer
```php
// 自定义命名空间,注意不要与已有的重复
// 必须与 composer.json 文件里 autoload 定义的路径一致
// "emacle\\HelloComposer\\": "src/"
namespace emacle\HelloComposer;// 类名与文件名保持一致,文件名不区分大小写
class HelloComposer
{
// 静态方法 static 使用时,可不用声明类,直接调用方法
public static function greet($greet = "Hello Composer!")
{
return $greet;
}
}
``````
composer require emacle/hello-composer
``````php
use emacle\HelloComposer\HelloComposer; // 引入 namespace 并加入类名 HelloComposergreet()); // 调用 HelloComposer类方法 greet()
var_dump(HelloComposer::greet()); // 如果类方法greet为 static 方法则不用声明直接调用
```