https://pear.php.net/package/PHP_UML/download
自动生成UML图的方法.
下载:http://pear.php.net/package/PHP_UML
假设, 我有一个项目文件夹:laruence, 在这个文件夹上有一个文件Root.php(事实上, 无论多级目录, 多个文件, 都可以).
<?php abstract class Root {
private $instance;
abstract public function Hi();
}
interface Intro {
public function Say();
}
class Sub extends Root implements Intro {
private $instance;
public function Say() {
echo “I am Laruence”;
}
public function Hi() {
echo “Hello!”;
}
}
?>
首先, 我们要使用PHP_UML(PHP_UML)根据代码生成XMI.
使用方法比较简单, 在安装PHP_UML以后, 运行:
pear安装PHP_UML命令的方法:/usr/local/php/bin/pear install PHP_UML-1.5.2
http://pear.php.net/package/PHP_UML/download
http://jackxiang.com/post/3147/
$pear install PHP_UML-1.6.2
No releases available for package “pear.php.net/PHP_UML”
install failed
一、PHP先生成xmi,后经过Altova UModel导入再生成html。
常用。
二、直接用PHPUML生成Html,将生成Html文档(定期在Linux机器上生成):
http://lifei123.blog.51cto.com/2487662/435638
/usr/local/php/bin/php /usr/local/php/bin/phpuml /data/htdocs/xiyou_alpha -e gbk -o /data/htdocs/tools.xiyou.cntv.cn/xiyou_php_uml/uml2html -f html –pure-object –no-deployment-view –no-component-view –no-docblocks
三、其它工具:利用Enterprise Architect识别PHP输出UML图:
http://leeon.me/a/How-to-use-Enterprise-Architect-to-output-UML
四、还有一个工具可以生成调用图::Altova MapForce,这个工具可以支持XMI到UML图的转换
http://www.icultivator.com/p/6191.html
五、UML多做一点PHP代码少写一点: http://www.linxun.info/?p=270
php ./phpuml /home/jackxiang/public_html/adc/web_adc_proj/trunk -o /root/software/PHP_UML-1.5.5/PHP/scripts/adcUmlGenFilter.xmi -n web_adc -f xmi –pure-object –no-deployment-view –no-component-view –no-docblocks
https://www.laruence.com/2010/05/14/1473.html
PHP_UML is a PHP parser, an XMI generator and a documentation tool.
PHP_UML是一个PHP解析器,XMI发生器和文档工具。
Practically, with PHP_UML, you will be able to feed a UML CASE tool, like Rational Rose or Argouml, with a UML representation of existing PHP source code. This way, you get an instant overview of a PHP application, with all the usual functions of a software design tool (such as class diagrams exportation, refactoring of object-oriented applications, or automatic code generation).
实际上,用PHP_UML,你将能够供给一个UML工具,如Rational Rose或Argouml,用现UML表示现有的PHP源代码。这样,你得到一个即时的概述一个PHP应用程序中,所有的一般功能软件设计工具(如类图出口、重构的面向对象的应用程序,或自动代码生成)。
PHP_UML:
可以生成UML / XMI文件在1.4版本中,或在版本2.1(逻辑、组件、部署视图)
可以将UML / XMI内容从1.4版本转到2.1版本
PHP_UML:
https://blog.51cto.com/lifei123/435638
https://blog.csdn.net/qq_23898357/article/details/80091437
https://www.cnblogs.com/thrillerz/p/4756763.html
pear.php.net无法解析
vim /etc/hosts
//增加
109.203.101.62 pear.php.net
http://www.80aj.com/3868.html
pear clear-cache
pear update-channels
pear upgrade
https://stackoverflow.com/questions/23563488/no-releases-available-for-package/23611129
$ pear clear-cache
/var/folders/r9/35q9g3d56_d9g0v59w9x2l9w0000gn/T//pear/cache does not exist or is not a directory
11:55:58-didi@bogon:~/Downloads/PHP_UML-1.6.2/PHP_UML-1.6.2$pear update-channels
Updating channel “doc.php.net”
Update of Channel “doc.php.net” succeeded
Updating channel “pear.php.net”
Channel “pear.php.net” is not responding over http://, failed with message: Connection to ssl://pear.php.net:443' failed: Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?
ssl://pear.php.net:443’ failed: Unable to find the socket transport “ssl” - did you forget to enable it when you configured PHP?)
Trying channel "pear.php.net" over https:// instead
Cannot retrieve channel.xml for channel "pear.php.net" (Connection to
Updating channel “pecl.php.net”
Update of Channel “pecl.php.net” succeeded
11:56:01-didi@bogon:~/Downloads/PHP_UML-1.6.2/PHP_UML-1.6.2$pear upgrade
Error getting channel info from pear.php.net: Connection to ssl://pear.php.net:443' failed: Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?
ssl://pear.php.net:443’ failed: Unable to find the socket transport “ssl” - did you forget to enable it when you configured PHP?
Error getting channel info from pear.php.net: Connection to
Error getting channel info from pear.php.net: Connection to ssl://pear.php.net:443' failed: Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?
ssl://pear.php.net:443’ failed: Unable to find the socket transport “ssl” - did you forget to enable it when you configured PHP?
Error getting channel info from pear.php.net: Connection to
Error getting channel info from pear.php.net: Connection to ssl://pear.php.net:443' failed: Unable to find the socket transport "ssl" - did you forget to enable it when you configured PHP?
ssl://pear.php.net:443’ failed: Unable to find the socket transport “ssl” - did you forget to enable it when you configured PHP?
Error getting channel info from pear.php.net: Connection to
Nothing to upgrade
https://stackoverflow.com/questions/31842400/ssl-issue-after-pear-channel-update-pear-php-net
$sudo pecl channel-update pecl.php.net
Updating channel “pecl.php.net”
Channel “pecl.php.net” is up to date
$ sudo pear install PHP_UML-1.6.2
No releases available for package “pear.php.net/PHP_UML”
install failed
$pear install ~/Downloads/PHP_UML-1.6.2.tgz
could not extract the package.xml file from “/Users/didi/Downloads/PHP_UML-1.6.2.tgz”
install failed
12:06:25-didi@bogon:~/Downloads/PHP_UML-1.6.2/PHP_UML-1.6.2$pear install ~/Downloads/PHP_UML-1.6.2
PHP_UML-1.6.2/ PHP_UML-1.6.2.tgz
12:06:25-didi@bogon:~/Downloads/PHP_UML-1.6.2/PHP_UML-1.6.2$pear install ~/Downloads/PHP_UML-1.6.2/
PHP_UML-1.6.2/ package.xml
12:06:25-didi@bogon:~/Downloads/PHP_UML-1.6.2/PHP_UML-1.6.2$pear install ~/Downloads/PHP_UML-1.6.2/
install failed
12:06:41-didi@bogon:~/Downloads/PHP_UML-1.6.2/PHP_UML-1.6.2$cd ~/Downloads/PHP_UML-1.6.2/
12:07:32-didi@bogon:~/Downloads/PHP_UML-1.6.2$pear install
PHP_UML-1.6.2/ package.xml
12:07:32-didi@bogon:~/Downloads/PHP_UML-1.6.2$pear install package.xml
Package “pear.php.net/PHP_UML” dependency “pear.php.net/Console_CommandLine” has no releases
pear/PHP_UML requires package “pear/Console_CommandLine”
pear/PHP_UML requires PHP extension “XSL”
No valid packages found
install failed
[root@localhost ~]# pear install Net_Socket-1.0.14.tgz
could not extract the package.xml file from Net_Socket-1.0.14.tgz
怀疑php没有zip之类的参数,需要手动解压,再进行安装,非常的浪费时间啊:
tar -axf Net_Socket-1.0.14.tgz -C /usr/local/src/
cd /usr/local/src/Net_Socket
pear install package.xml
https://pear.php.net/manual/en/guide.users.commandline.installing.php
https://pear.php.net/package/Console_CommandLine/download
curl -O http://download.pear.php.net/package/Console_CommandLine-1.2.2.tgz
$cd Console_CommandLine-1.2.2
12:10:34-didi@bogon:~/Downloads/PHP_UML-1.6.2/Console_CommandLine-1.2.2$ls
Console_CommandLine-1.2.2 package.xml
12:10:35-didi@bogon:~/Downloads/PHP_UML-1.6.2/Console_CommandLine-1.2.2$pear install package.xml
Warning: require_once(Structures/Graph.php): Failed to open stream: No such file or directory in Downloader.php on line 1213
PHP Warning: require_once(Structures/Graph.php): Failed to open stream: No such file or directory in /usr/local/lib/php/PEAR/Downloader.php on line 1213
Warning: require_once(Structures/Graph.php): Failed to open stream: No such file or directory in /usr/local/lib/php/PEAR/Downloader.php on line 1213
PHP Fatal error: Uncaught Error: Failed opening required ‘Structures/Graph.php’ (include_path=’/usr/local/lib/php:/usr/local/lib/php’) in /usr/local/lib/php/PEAR/Downloader.php:1213
Stack trace:
#0 /usr/local/lib/php/PEAR/Command/Install.php(709): PEAR_Downloader->sortPackagesForInstall(Array)
#1 /usr/local/lib/php/PEAR/Command/Common.php(270): PEAR_Command_Install->doInstall(‘install’, Array, Array)
#2 /usr/local/lib/php/pearcmd.php(317): PEAR_Command_Common->run(‘install’, Array, Array)
#3 {main}
thrown in /usr/local/lib/php/PEAR/Downloader.php on line 1213
Fatal error: Uncaught Error: Failed opening required ‘Structures/Graph.php’ (include_path=’/usr/local/lib/php:/usr/local/lib/php’) in /usr/local/lib/php/PEAR/Downloader.php:1213
Stack trace:
#0 /usr/local/lib/php/PEAR/Command/Install.php(709): PEAR_Downloader->sortPackagesForInstall(Array)
#1 /usr/local/lib/php/PEAR/Command/Common.php(270): PEAR_Command_Install->doInstall(‘install’, Array, Array)
#2 /usr/local/lib/php/pearcmd.php(317): PEAR_Command_Common->run(‘install’, Array, Array)
#3 {main}
thrown in /usr/local/lib/php/PEAR/Downloader.php on line 1213
https://stackoverflow.com/questions/5625935/pear-error-require-oncestructures-graph-node-php-failed-to-open-stream
$curl -O http://download.pear.php.net/package/Structures_Graph-1.1.1.tgz
$cd Structures_Graph-1.1.1
$pear install package.xml
Ignoring installed package pear/Structures_Graph
Nothing to install
$pear list
Installed packages, channel pear.php.net:
=========================================
Package Version State
Archive_Tar 1.4.9 stable
Console_Getopt 1.4.3 stable
PEAR 1.10.12 stable
PhpDocumentor 1.4.4 stable
Structures_Graph 1.1.1 stable
XML_Util 1.4.5 stable
$pear uninstall Structures_Graph
pear/Structures_Graph (recommended version 1.1.1) is required by installed package “pear/PEAR”
pear/Structures_Graph cannot be uninstalled, other installed packages depend on this package
It seems your PEAR directory address is wrong in your PHP.ini file.
Please run this command and say what you see :
pear config-show
https://pear.php.net/bugs/bug.php?id=18332
rm -r /Users/didi/pear/share/pear//PEAR
ln -s /usr/local/lib/php/PEAR/ /Users/didi/pear/share/pear/
rm -rf /Users/didi/pear/share/pear
$mv /usr/local/lib/php/PEAR /usr/local/lib/php/PEAR.bak
pecl install swoole 报错
unexpected ‘new’ (T_NEW) in /usr/share/pear/PEAR/ 这里报的错是pecl的原因造成的
提示:syntax error, unexpected ‘new’ (T_NEW) in /usr/share/pear/PEAR/Frontend.php on line 91
解决方法:
$ wget http://pear.php.net/go-pear.phar
$ php go-pear.phar
$ ln -s /usr/local/php/bin/pecl /usr/bin/pecl
然后就可以 pecl install xxxx 了
$ yum -y install php-pear
//否则会报错PHP Parse error: syntax error, unexpected //’new’ (T_NEW) in /usr/share/pear/PEAR/Frontend.php on //line 91
$ curl -O http://pear.php.net/go-pear.phar
$curl -O http://download.pear.php.net/package/Structures_Graph-1.1.1.tgz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 12579 100 12579 0 0 9599 0 0:00:01 0:00:01 –:–:– 9594
$curl -O https://pear.php.net/go-pear.phar
$curl -O http://download.pear.php.net/package/PEAR-1.10.8.tgz
$pear install package.xml
Package “pear.php.net/PEAR” dependency “pear.php.net/Archive_Tar” has no releases
Package “pear.php.net/PEAR” dependency “pear.php.net/Structures_Graph” has no releases
Package “pear.php.net/PEAR” dependency “pear.php.net/Console_Getopt” has no releases
Package “pear.php.net/PEAR” dependency “pear.php.net/XML_Util” has no releases
pear/PEAR requires package “pear/Archive_Tar” (recommended version 1.4.4)
pear/PEAR requires package “pear/Structures_Graph” (recommended version 1.1.1)
pear/PEAR requires package “pear/Console_Getopt” (recommended version 1.4.1)
pear/PEAR requires package “pear/XML_Util” (recommended version 1.4.3)
No valid packages found
install failed
PECL(The PHP Extension Community Library)是 PHP 扩展的存储库,为 PHP 所有的扩展提供提供托管和下载服务。
通过 PEAR(PHP Extension and Application Repository)的 Package Manager 的安装管理方式,可以对 PECL 扩展进行下载和安装。
$pear version
PEAR Version: 1.10.12
PHP Version: 8.0.0-dev
Zend Engine Version: 4.0.0-dev
Running on: Darwin bogon 15.0.0 Darwin Kernel Version 15.0.0: Sat Sep 19 15:53:46 PDT 2015; root:xnu-3247.10.11~1/RELEASE_X86_64 x86_64
$ curl -O https://pear.php.net/go-pear.phar
$mv Structures_Graph-1.1.1/* /usr/local/lib/php
$pecl install package.xml
ERROR: file ./docs/tutorials/Structures_Graph/Structures_Graph.pkg does not exist
$pecl install ../package.xml
ERROR: file ../Console/CommandLine/Action.php does not exist
$cp ../package.xml .
$pecl install ./package.xml
install ok: channel://pear.php.net/Console_CommandLine-1.2.2
$pecl install ./package.xml
pear.php.net is using a unsupported protocol - This should never happen.
pear/PHP_UML requires PHP extension “XSL”
No valid packages found
install failed
cd PhpstormProjects/c/php-src/ext/
cd xsl/
phpize
./configure
make
make install
vi /usr/local/lib/php.ini
extension=xsl.so
$pear install package.xml
Package “pear.php.net/PHP_UML” dependency “pear.php.net/Console_CommandLine” has no releases
ERROR: file ./data/phpuml.xml does not exist
$cp ../package.xml .
$pear install package.xml
Package “pear.php.net/PHP_UML” dependency “pear.php.net/Console_CommandLine” has no releases
install ok: channel://pear.php.net/PHP_UML-1.6.2
$phpuml -h
PHP Warning: require_once(PEAR/Exception.php): Failed to open stream: No such file or directory in /Users/didi/pear/share/pear/Console/CommandLine/Exception.php on line 28
Warning: require_once(PEAR/Exception.php): Failed to open stream: No such file or directory in /Users/didi/pear/share/pear/Console/CommandLine/Exception.php on line 28
PHP Fatal error: Uncaught Error: Failed opening required ‘PEAR/Exception.php’ (include_path=’.:/Users/didi/pear/share/pear’) in /Users/didi/pear/share/pear/Console/CommandLine/Exception.php:28
$pear list
Installed packages, channel pear.php.net:
=========================================
Package Version State
Console_CommandLine 1.2.2 stable
PHP_UML 1.6.2 stable
$cp ../package.xml .
$pear install package.xml
install ok: channel://pear.php.net/Structures_Graph-1.1.1
curl -O http://download.pear.php.net/package/PEAR_Exception-1.0.0.tgz
PEAR_Exception-1.0.0$pear install package.xml
install ok: channel://pear.php.net/PEAR_Exception-1.0.0
$phpuml
Error: You must provide at least 1 argument.
Type “/Users/didi/pear/bin/phpuml –help” to get help.
$phpuml -o ./uml/ ~/phpproj/
PHP Fatal error: Uncaught Error: Call to undefined function each() in /Users/didi/pear/share/pear/PHP/UML/Input/PHP/ParserImpl.php:867
Stack trace:
#0 /Users/didi/pear/share/pear/PHP/UML/Input/PHP/ParserImpl.php(205): PHP_UML_Input_PHP_ParserImpl->tNextDocComment(Array)
返回数组中当前的键/值对并将数组指针向前移动一步
This function has been DEPRECATED as of PHP 7.2.0. Relying on this function is highly discouraged.
https://www.php.net/manual/zh/function.each.php
https://pear.php.net/manual/en/package.php.php-uml.intro.php
<?php
require_once ‘PHP/UML.php’;
$uml = new PHP_UML();
$uml->setInput(‘tests’); // this defines which files/folders to parse (here, the folder “tests”)
$uml->parse(‘myApp’); // this starts the parser, and gives the name “myApp” to the generated metamodel
$uml->export(‘xmi’, ‘myApp.xmi’); // this serializes the metamodel in XMI code, and saves it to a file “myApp.xmi”
2、each函数已被废弃:
之前版本写法:
<?php
$array = array();
each($array);
// Deprecated: The each() function is deprecated. This message will be suppressed on further calls 在7.2版本中会提示过时,可以使用foreach替代each方法,也可以自己修改each方法替代:
<?php
function func_new_each(&$array){
$res = array();
$key = key($array);
if($key !== null){
next($array);
$res[1] = $res[‘value’] = $array[$key];
$res[0] = $res[‘key’] = $key;
}else{
$res = false;
}
return $res;
}
https://www.jianshu.com/p/81ff3d405b5d
phpuml laruence/ -o laruence.xmi -n laruence -f xmi –pure-object –no-deployment-view –no-component-view –no-docblocks
https://www.laruence.com/2010/05/14/1473.html
https://www.visual-paradigm.com/cn/download/?platform=macosx&arch=jre
Not my field, but Visual Paradigm may help. Not sure why it didn’t work for you. They also provide integration with IntelliJ IDEA, so you can contact them and ask if they have a plug-in for PhpStorm.
https://stackoverflow.com/questions/13012174/phpstorm-uml-diagrams-and-xmi-files
https://blog.csdn.net/xiaoxinshuaiga/article/details/77804007
phpstorm安装UML插件PlantUML
在File->Settings->Plugins中查找PlantUML
https://www.visual-paradigm.com/cn/download/community.jsp?platform=macosx&arch=jre