php-ftp连接示例

<meta charset="UTF-8">

<?php
$ftp_server_host = "192.168.1.1";
$ftp_user_name = "name";
$ftp_user_pass = "password";

//建立基础连接
$ftp_connect = ftp_connect($ftp_server_host);

if ($ftp_connect) {
    //使用用户名和口令登录
    $login_result = ftp_login($ftp_connect, $ftp_user_name, $ftp_user_pass);
    
    if ($login_result) {
        
        $flag = ftp_pasv($ftp_connect, true);  //打开被动模式
        var_dump($flag);
        
        $pwd = ftp_pwd($ftp_connect);  //当前ftp的目录
        var_dump($pwd);

//      遍历目录(非递归)
        $remote_path = "/";
        $file_arr = ftp_nlist($ftp_connect, $remote_path);
        var_dump($file_arr);
        
//      上传文件(需要先开启 被动模式)(如果已经存在 无法上传)
        $remote_file = "a.txt";
        $local_file = "d:/ftp_up_test.txt";
        $flag = ftp_put($ftp_connect, $remote_file, $local_file, FTP_BINARY);
        var_dump($flag);

//      下载文件(需要先开启 被动模式)
        $remote_file = "a.txt";
        $local_file = "d:/ftp_down_test.txt";
        $flag = ftp_get($ftp_connect, $local_file, $remote_file, FTP_BINARY);
        var_dump($flag);
    
//      删除文件
        $remote_file = "a.php";
        $flag = ftp_delete($ftp_connect, $remote_file);
        var_dump($flag);
        
//      修改文件权限(此文件需要 登陆账号有权限去进行 chmod)
        $remote_file = "a.txt";
        $flag = ftp_chmod($ftp_connect, 0777, $remote_file);
        var_dump($flag);
        
    } else {
        echo "用户登陆失败";
    }
    
    //关闭连接
    ftp_close($ftp_connect);
} else {
    echo "连接ftp服务器失败";
}
?>

Laravel 学习笔记

启动
php artisan serve

数据库表
php artisan migrate

创建controller
php artisan make:controller [controller名称]

配置修改不生效
php artisan config:clear

创建邮件配置
php artisan make:mail SendMailCode

创建表生成器
php artisan make:migration create_talks_table


创建控制器并且创建表生成器
php artisan make:model test --migration

app/Providers/AppServiceProvider.php

use Illuminate\Support\Facades\Schema;

public function boot()
{
Schema::defaultStringLength(191);
}

模板控制器激活判定
composer require hieu-le/active

cnetos7 安装php7.1 支持workerman

准备工作

wget http://hk1.php.net/distributions/php-7.1.4.tar.gz
tar zxvf php-7.1.4.tar.gz 
cd php-7.1.4/

编译所需模块安装

yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel curl curl-devel openssl openssl-devel gcc 

检测依赖项, 设置编译支持模块

./configure --prefix=/usr/local/php --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --with-mysqli --with-zlib --with-curl --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-openssl --enable-mbstring --enable-xml --enable-session --enable-ftp --enable-pdo -enable-tokenizer --enable-zip --enable-posix --enable-pcntl

编译与安装

make && make install

查看版本

/usr/local/php/bin/php -v

查看模块

/usr/local/php/bin/php -m