小编Lui*_*uis的帖子

用于在php中转换为图像的开箱即用文本

我正在尝试将文本转换为图像.我已经这样做了,但有些情况下文本不在图像框中图片

"The"这个词的"e"被删除了.我尝试过减小字体大小或增加图像的宽度,但在某些情况下,这会再次发生在另一个文本中.这是代码:

    $new_line_position = 61;        
    $angle = 0;        
    $left = 20;
    $top = 45;
    $image_width = 1210;
    $image_line_height = 45;                

    $content_input = wordwrap($content_input,    $new_line_position, "\n", true);  

    $lineas = preg_split('/\\n/', $content_input);
    $lines_breaks = count($lineas); 
    $image_height = $image_line_height * $lines_breaks;
    $im = imagecreatetruecolor($image_width, $image_height);

    // Create some colors
    $white = imagecolorallocate($im, 255, 255, 255);        
    $black = imagecolorallocate($im, 0, 0, 0);
    imagefilledrectangle($im, 0, 0, $image_width, $image_height, $white);   

   $font_ttf =  public_path().'/fonts/'.$ttf_font;                     


    foreach($lineas as $linea){
        imagettftext($im, $font_size, $angle, $left, $top, $black, $font_ttf, $linea);        
        $top = …
Run Code Online (Sandbox Code Playgroud)

php fonts gd truetype imagettftext

11
推荐指数
1
解决办法
687
查看次数

使用 mix 将 jquery stellar 插件添加到 laravel 5.4 项目

我是 Laravel Mix 的新手,我无法添加 jquery 库 stellar,当我尝试npm run dev时,它向我显示此错误:未找到此依赖项:* jquery.stellar in ./resources/assets/js/bootstrap. js

但我已经使用npm install --save jquery.stellarnpm install jquery.stellar安装了它

这是我的 webpack 文件:webpack.mix.js:

const { mix } = require('laravel-mix');

/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel application. By default, we are compiling the Sass
 | file for the application as well as bundling up all the JS files. …
Run Code Online (Sandbox Code Playgroud)

javascript jquery node.js laravel-5 laravel-mix

5
推荐指数
1
解决办法
1185
查看次数

测试用户是否登录 laravel 5.7

我正在做一个测试,但是当它尝试检查用户是否登录时失败了:

<?php

namespace Tests\Feature;

use Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Auth;
use App\User;

class RegisterTest extends TestCase
{

    use RefreshDatabase;

    /*.....
    more test about registering
     ....*/    

    /** @test */
    function redirect_to_home_page_and_logged_in_after_login()
    {                   

        $user = factory(User::class)->create([
            'name' => 'Test',
            'email' => 'test@hotmail.com', 
            'password' => '123456'
        ]);     

        $response = $this->post('login', [
            'email' => 'test@hotmail.com',
            'password' => '123456'          
        ]);

        //this works
        $response->assertRedirect('/');

        //this fails 
        $this->assertTrue(Auth::check());


    }
}
Run Code Online (Sandbox Code Playgroud)

这是我的控制器 HomeController:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class HomeController extends Controller
{


    public function index() …
Run Code Online (Sandbox Code Playgroud)

php phpunit laravel

3
推荐指数
2
解决办法
4648
查看次数

使用axios上传和patch方法不起作用

我使用 Laravel 5.8 和 Vue.js 2,这是我的 .vue 文件:

let data = new FormData();                           
data.append('name', this.name);
data.append('image',this.image)
data.append('_method', 'PATCH');
axios.patch('/url/' + this.id, data)                        
                     .then(({data}) => {                

                    })
                     .catch((error) => {

                    }); 
Run Code Online (Sandbox Code Playgroud)

路线

let data = new FormData();                           
data.append('name', this.name);
data.append('image',this.image)
data.append('_method', 'PATCH');
axios.patch('/url/' + this.id, data)                        
                     .then(({data}) => {                

                    })
                     .catch((error) => {

                    }); 
Run Code Online (Sandbox Code Playgroud)

错误

违反完整性约束:1048 列“名称”不能为空。

但是当我将方法更改为 POST 时,在我的 vue 文件和 web.php 中它都有效,发生了什么?我需要使用两种方法:发布新数据和修补更新。我能做些什么?

javascript form-data laravel vue.js axios

1
推荐指数
1
解决办法
2154
查看次数