Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
youfeed committed Nov 8, 2024
0 parents commit 9edbf91
Show file tree
Hide file tree
Showing 5 changed files with 557 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Youloge.tool Webman 辅助函数百宝箱

> 使用前看一下下面辅助函数:尤其注意`函数名称得问题`:不适合老项目:老项目可以选择查询源码,把代码片段复制出来使用
### 项目地址

[Github Youloge.Tool](https://github.com/youfeed/webman.tool) Star我 `我们一起做大做强`

- 0.0.1 初始项目

### 有帮助的话,记得给个star 打赏打赏,代码风格极简 欢迎提交代码

> `composer require youloge/webman.tool`

### 使用说明

- `config/youloge.php` 新增一个配置文件(升级时候不影响配置)
-
16 changes: 16 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "youloge/webman.tool",
"type": "library",
"license": "MIT",
"description": "Webman plugin youloge/webman.tool",
"require": {
},
"autoload": {
"psr-4": {
"Youloge\\Webman.tool\\": "src"
},
"files": [
"src/helpers.php"
]
}
}
74 changes: 74 additions & 0 deletions src/Install.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php
namespace Youloge\Webman.tool;

class Install
{
const WEBMAN_PLUGIN = true;

/**
* @var array
*/
protected static $pathRelation = array (
'config/plugin/youloge/webman.tool' => 'config/plugin/youloge/webman.tool',
);

/**
* Install
* @return void
*/
public static function install()
{
static::installByRelation();
}

/**
* Uninstall
* @return void
*/
public static function uninstall()
{
self::uninstallByRelation();
}

/**
* installByRelation
* @return void
*/
public static function installByRelation()
{
foreach (static::$pathRelation as $source => $dest) {
if ($pos = strrpos($dest, '/')) {
$parent_dir = base_path().'/'.substr($dest, 0, $pos);
if (!is_dir($parent_dir)) {
mkdir($parent_dir, 0777, true);
}
}
//symlink(__DIR__ . "/$source", base_path()."/$dest");
copy_dir(__DIR__ . "/$source", base_path()."/$dest");
echo "Create $dest
";
}
}

/**
* uninstallByRelation
* @return void
*/
public static function uninstallByRelation()
{
foreach (static::$pathRelation as $source => $dest) {
$path = base_path()."/$dest";
if (!is_dir($path) && !is_file($path)) {
continue;
}
echo "Remove $dest
";
if (is_file($path) || is_link($path)) {
unlink($path);
continue;
}
remove_dir($path);
}
}

}
4 changes: 4 additions & 0 deletions src/config/plugin/youloge/webman.tool/app.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
return [
'enable' => true,
];
Loading

0 comments on commit 9edbf91

Please sign in to comment.