Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0ece14d

Browse files
committed
添加卸载class
1 parent 30cc834 commit 0ece14d

File tree

4 files changed

+66
-10
lines changed

4 files changed

+66
-10
lines changed

‎README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
##PHPOpenCV Installer
1+
##PHPOpenCV Installer
22

33

44
First, download the PHPOpenCV installer using Composer:

‎phpopencv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ if (file_exists(__DIR__.'/../../autoload.php')) {
88
}
99
$app = new Symfony\Component\Console\Application('PHPOpenCV Installer', '1.0.0');
1010
$app->add(new CV\Installer\Console\InstallCommand);
11+
$app->add(new CV\Installer\Console\UninstallCommand);
1112
$app->run();

‎src/InstallCommand.php

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ class InstallCommand extends Command
1717
const EXTENSION_NAME = 'opencv';
1818
const OPENCV_VERSION = '4.0.0';
1919

20+
protected $installInfo = [];
21+
2022
/**
2123
* Configure the command options.
2224
*
@@ -45,7 +47,7 @@ protected function configure()
4547
protected function buildEnvDetection()
4648
{
4749
$shellPath = __DIR__ . '/../opencv-install-environment-detection.sh';
48-
$process = new Process([$shellPath]);//给予当前用户
50+
$process = new Process([$shellPath]);//todo 给予当前用户
4951
try {
5052
$process->mustRun();
5153
} catch (\Exception $e) {
@@ -121,7 +123,6 @@ protected function findExistOpenCV(OutputInterface $output)
121123
protected function execute(InputInterface $input, OutputInterface $output)
122124
{
123125

124-
125126
//判断是否已经安装opencv扩展
126127
if (extension_loaded(self::EXTENSION_NAME)) {
127128
$process = new Process(['php', '--ri', self::EXTENSION_NAME]);
@@ -145,18 +146,24 @@ protected function execute(InputInterface $input, OutputInterface $output)
145146
}
146147

147148
}
149+
//克隆项目
148150
$this->cloneOpenCV($directory);
149151
$this->cloneOpenCVContrib($directory);
150-
//
152+
153+
//编译安装
151154
$commands = [
152-
'cd opencv'
155+
'cd opencv',
156+
'mkdir build',
157+
'cd build',
158+
'pwd'
153159
];
154160
$cloneOpenCVDirectory = $directory . '/opencv';
155-
$commands = [
156-
'mkdir build'
157-
];
158-
$command = 'mkidr && cd build';
159-
//编译安装
161+
$process = new Process(implode(' && ', $commands), $directory, null, null, null);
162+
$process->run(function ($type, $line) use ($output) {
163+
$output->write($line);
164+
});
165+
//编译扩展
166+
160167
$output->writeln('<comment>Application ready! Build something amazing.</comment>');
161168
}
162169
}

‎src/UninstallCommand.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: hiho
5+
* Date: 19-4-11
6+
* Time: 下午7:11
7+
*/
8+
9+
namespace CV\Installer\Console;
10+
11+
12+
use Symfony\Component\Console\Command\Command;
13+
use Symfony\Component\Console\Input\InputInterface;
14+
use Symfony\Component\Console\Output\OutputInterface;
15+
16+
class UninstallCommand extends Command
17+
{
18+
/**
19+
* Configure the command options.
20+
*
21+
* @return void
22+
*/
23+
protected function configure()
24+
{
25+
$this
26+
->setName('uninstall')
27+
->setDescription('Uninstall PHPOpenCV extension and OpenCV');
28+
}
29+
30+
31+
/**
32+
* Execute the command.
33+
*
34+
* @param \Symfony\Component\Console\Input\InputInterface $input
35+
* @param \Symfony\Component\Console\Output\OutputInterface $output
36+
*
37+
* @return void
38+
*/
39+
protected function execute(InputInterface $input, OutputInterface $output)
40+
{
41+
42+
//卸载扩展
43+
//cd /opt/opencv/opencv/build
44+
//sudo make uninstall
45+
//sudo find . -name "*opencv*" | xargs sudo rm -rf
46+
47+
}
48+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /