好几次遇到阿里云的镜像更新有问题了,明明某个库有了最新版,但阿里云就是报版本不存在。今天又出现了这样的情况,安装laravel-zero的时候,require-dev中有个laravel/pint ^1.2,直接就报了
Problem 1
- Root composer.json requires laravel/pint ^1.2, found laravel/pint[dev-main, v0.1.0, ..., v0.2.4, v1.0.0, ..., v1.1.3] but it does not match the constraint.
由于之前也遇到过这个问题,当时是unset掉 aliyun镜像,换成了官方镜像,但确实是慢,所以我就看了一眼其他镜像,比如以前常用的https://packagist.phpcomposer.com,在国内没有其他镜像的时候,它做了很大的贡献,然而也太不稳定了。直接报:
Problem 1 - Root composer.json requires laravel-zero/framework, it could not be found in any version, there may be a typo in the package name. Problem 2 - Root composer.json requires nunomaduro/termwind, it could not be found in any version, there may be a typo in the package name. Problem 3 - Root composer.json requires laravel/pint, it could not be found in any version, there may be a typo in the package name. Problem 4 - Root composer.json requires mockery/mockery, it could not be found in any version, there may be a typo in the package name. Problem 5 - Root composer.json requires pestphp/pest, it could not be found in any version, there may be a typo in the package name. Potential causes: - A typo in the package name - The package is not available in a stable-enough version according to your minimum-stability setting see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details. - It's a private package and you forgot to add a custom repository to find it Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.
看来,已经多年没有更新过了,真可惜了。
配好之后,composer u,完成。记录一下
1、阿里:composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
2、腾讯:composer config -g repos.packagist composer https://mirrors.tencent.com/composer/
3、清除:composer config -g --unset repos.packagist
带 -g 的是全局的,不带 -g,就是当前项目了。
PHP有不少Redis库,比如pecl的Redis库(phpredis),就是直接自带了数组的存取和读出,因为他在存储和读出的时候自动序列化了。象是象predis就不行,如果你直接存一个数组去,那么它就会报warning,同时存一个Array到指定的KEY上。
但是predis允许你封装自定义的redis方法。比如jsonset/jsonget,这时候你利用这些自定义的方法来获取或写入数组即可。(基于Laravel,其他的也一样,其他参考:Setting arrays · Issue #136 · predis/predis (github.com))
只是官方的Issue中 【Predis\Profile\ServerProfile:】已经不存在了,要换成【Predis\Profile\Factory】,其余可以复制
----
基于Laravel的话,上述的数组可以放到config里,就啥出不用配置了~~
PHP代码
- if (!function_exists('yredis')) {
- class StringSetJson extends Predis\Command\StringSet
- {
- protected function filterArguments(array $arguments)
- {
- $arguments[1] = json_encode($arguments[1]);
- return $arguments;
- }
- }
-
- class StringGetJson extends Predis\Command\StringGet
- {
- public function parseResponse($data)
- {
- return json_decode($data, true);
- }
- }
-
- class StringSetPhp extends Predis\Command\StringSet
- {
- protected function filterArguments(array $arguments)
- {
- $arguments[1] = serialize($arguments[1]);
- return $arguments;
- }
- }
-
- class StringGetPhp extends Predis\Command\StringGet
- {
- public function parseResponse($data)
- {
- return unserialize($data);
- }
- }
-
-
-
-
-
-
- function yredis()
- {
- try {
- $redis = app('yredis');
- } catch (Exception $e) {
- app()->singleton('yredis', function ($app) {
- $config = $app->make('config')->get('database.redis', []);
- unset($config['options']['prefix']);
- if(env('REDIS_CLIENT') == 'predis'){
- $config['options']['profile'] = function ($options, $option) {
- $profile = \Predis\Profile\Factory::getDefault();
- $profile->defineCommand('jsonset', 'StringSetJson');
- $profile->defineCommand('jsonget', 'StringGetJson');
- $profile->defineCommand('phpset', 'StringSetPhp');
- $profile->defineCommand('phpget', 'StringGetPhp');
- return $profile;
- };
- }
- return new \Illuminate\Redis\RedisManager($app, \Illuminate\Support\Arr::pull($config, 'client', 'phpredis'), $config);
- });
- app()->bind('yredis.connection', function ($app) {
- return $app['yredis']->connection();
- });
- $redis = app('yredis');
- }
- return $redis;
- }
- }
因为laravel的默认config会带 prefix,所以写一个简单的,其实就是为了在写数据的时候不加 prefix 。。。
如题
比如,你定义了一个方法,
PHP代码
- function test():never {
- exit(1);
- }
在其他方法使用的时候,
PHP代码
- doSomething(){
- test() ;
- echo 123;
- }
在IDE里,会提示这个echo 123;的错误是unreachable
原来phpstorm支持:#[NoReturn] 这个注释,但现在有语法级的支持,则变得更舒服。
----
然而,现在线上用的还是PHP7.3。连fn=> 这个功能都用不了。还有就是对于对象的操作$a?->b?->c也用不了。。。
只能接着忍,Laravel 9最低要8.0了,估计可能会强制更新了
使用fpdf读取PDF文件时,报错:This PDF document probably uses a compression technique which is not supported by the free parser shipped with FPDI. (See https://www.setasign.com/fpdi-pdf-parser for more details)
提示这个文件是采用了一个压缩格式,到官网上查看之后,发现他们提供了fpdi-pdf-paser2,但是这是收费的。。。啊啊啊,短时间内先忽略吧。毕竟这样的PDF不多。
后面再关注一下有没有类似的东西。
2、查看这里的测试代码和示例:https://www.setasign.com/products/fpdi-pdf-parser/details/
目前我是放弃了,因为,他develop version,要100欧,然而这只是我自己用来测试,没必要。
------
后记:
1、读了PDF的第一行,发现这个PDF版本是PDF1.5,尝试用chrome打开,另存为,无效。选择打印->另存为PDF,成功
PHP代码
-
- <?php
- exec('gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile="'.$srcfile_new.'" "'.$srcfile.'"');
- ?>
结果,官网上没有mac的可执行文件,又不想编译,所以纯记录一下吧
-----
0227更新:
GPL Ghostscript 9.50 (2019-10-15)
Copyright (C) 2019 Artifex Software, Inc. All rights reserved.
This software is supplied under the GNU AGPLv3 and comes with NO WARRANTY:
see the file COPYING for details.
GPL Ghostscript 9.50: Cannot open X display `(null)'.
**** Unable to open the initial device, quitting.
纠结。
在使用本地valet进行开发的时候,打开刚指定的域名,出现:ERR_EMPTY_RESPONSE
命令行下访问一切正常:curl http://xxx.dev 都能够正常访问,但就是网页不行。因此问题不是出在了所谓的防火墙上(网上很多搜到的资料都是说防火墙)
试着清除浏览器缓存之类的,发现没正常,因为我换了chrome/edge/safari,都是同样的问题。
这时候开始怀疑网络问题了。因为在访问前正好将 global 模式换成了 pac mode,于是关闭APP,访问恢复。
这个问题应该是在切换网络的时候,系统缓存下来了。但命令行里却是正常。。。
做了几次测试
1、打开PAC模式,断开网络,本地网站恢复,连接后继续不正常
2、关闭PAC模式,恢复,打开后不正常
3、因为valet的其他站点正常,尝试unlink再link ,并没有效果
4、valet secure后,https访问,正常。关闭后继续无法访问 【这里还很妖,safari在https下可以访问,edge/chrome不行】
5、sudo brew services restart dnsmasq ,无效。
6、。。。。。没重启,毕竟机器 已经运行60多天了(12:13 up 68 days, 20:44, 6 users, load averages: 2.22 2.96 3.27),先缓缓
---暂先使用valet secure进行访问吧
---updated 01-03 16:00
这个缓存不知道怎么处理了,换了一个link,恢复了。valet link othername。。。正常,难道blog这个域名有问题??