国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

? php教程 PHP開發(fā) SmartWiki, Laravel ?? ?? ?? ??

SmartWiki, Laravel ?? ?? ?? ??

Dec 02, 2016 pm 04:39 PM
laravel

SmartWiki ?? ???? Alibaba Cloud? ???? ??? Alibaba Cloud?? 128M? ?? Memcache ???? ????. Memcached ?? ??? ?? ??? ? Laravel?? ??? ??? ?? ????? ?? ??? ??? ????. addServer? ??? ?? Alibaba Cloud? Memcache? ??? ? ????.

????? ???? ???? ?? ???? ????? ?? ??? ???? ???? ? ? ????.

Alibaba Cloud?? ???? ????? ??? ????.

<?php
$connect = new Memcached;  //聲明一個新的memcached鏈接
$connect->setOption(Memcached::OPT_COMPRESSION, false); //關(guān)閉壓縮功能
$connect->setOption(Memcached::OPT_BINARY_PROTOCOL, true); //使用binary二進(jìn)制協(xié)議
$connect->addServer(&#39;00000000.ocs.aliyuncs.com&#39;, 11211); //添加OCS實(shí)例地址及端口號
//$connect->setSaslAuthData(&#39;aaaaaaaaaa, &#39;password&#39;); //設(shè)置OCS帳號密碼進(jìn)行鑒權(quán),如已開啟免密碼功能,則無需此步驟
$connect->set("hello", "world");
echo &#39;hello: &#39;,$connect->get("hello");
print_r( $connect->getVersion());
$connect->quit();

laravel? Memcached ????? ???? /vendor/laravel/framework/src/Illuminate/Cache/MemcachedConnector? Memcached ??? ?????. .php ??? ??? ????.

public function connect(array $servers)
{
    $memcached = $this->getMemcached();
    // For each server in the array, we&#39;ll just extract the configuration and add
    // the server to the Memcached connection. Once we have added all of these
    // servers we&#39;ll verify the connection is successful and return it back.
    foreach ($servers as $server) {
        $memcached->addServer(
            $server[&#39;host&#39;], $server[&#39;port&#39;], $server[&#39;weight&#39;]
        );
    }
    $memcachedStatus = $memcached->getVersion();
    if (! is_array($memcachedStatus)) {
        throw new RuntimeException(&#39;No Memcached servers added.&#39;);
    }
    if (in_array(&#39;255.255.255&#39;, $memcachedStatus) && count(array_unique($memcachedStatus)) === 1) {
        throw new RuntimeException(&#39;Could not establish Memcached connection.&#39;);
    }
    return $memcached;
}

laravel? Memcached??? ?? ??? ?? ??? ???? getVersion? ???? ?? ??? ??????. ???????. Alibaba Cloud? ?? ??? ??? ?? ???? ???? ????? ???? ??? ?????.

??? ??? ????? Memcached? ??? ???? ??? ????. laravel? ?? ??? Cache::extend? ???? ??? ? ????. ?? ??? ??? ????.

Cache::extend(&#39;MemcachedExtend&#39;, function ($app) {

    $memcached = $this->createMemcached($app);

    // 從配置文件中讀取緩存前綴
    $prefix = $app[&#39;config&#39;][&#39;cache.prefix&#39;];

    // 創(chuàng)建 MemcachedStore 對象
    $store = new MemcachedStore($memcached, $prefix);

    // 創(chuàng)建 Repository 對象,并返回
    return new Repository($store);
});
/**
 * 創(chuàng)建Memcached對象
 * @param $app
 * @return mixed
 */
protected function createMemcached($app)
{
    // 從配置文件中讀取 Memcached 服務(wù)器配置
    $servers = $app[&#39;config&#39;][&#39;cache.stores.MemcachedExtend.servers&#39;];


    // 利用 Illuminate\Cache\MemcachedConnector 類來創(chuàng)建新的 Memcached 對象
    $memcached = new \Memcached;

    foreach ($servers as $server) {
        $memcached->addServer(
            $server[&#39;host&#39;], $server[&#39;port&#39;], $server[&#39;weight&#39;]
        );
    }

    // 如果服務(wù)器上的 PHP Memcached 擴(kuò)展支持 SASL 認(rèn)證
    if (ini_get(&#39;memcached.use_sasl&#39;) && isset($app[&#39;config&#39;][&#39;cache.storess.MemcachedExtend.memcached_user&#39;]) && isset($app[&#39;config&#39;][&#39;cache.storess.MemcachedExtend.memcached_pass&#39;])) {

        // 從配置文件中讀取 sasl 認(rèn)證用戶名
        $user = $app[&#39;config&#39;][&#39;cache.storess.MemcachedExtend.memcached_user&#39;];

        // 從配置文件中讀取 sasl 認(rèn)證密碼
        $pass = $app[&#39;config&#39;][&#39;cache.storess.MemcachedExtend.memcached_pass&#39;];

        // 指定用于 sasl 認(rèn)證的賬號密碼
        $memcached->setSaslAuthData($user, $pass);
    }

    //擴(kuò)展
    if (isset($app[&#39;config&#39;][&#39;cache.stores.MemcachedExtend.options&#39;])) {
        foreach ($app[&#39;config&#39;][&#39;cache.stores.MemcachedExtend.options&#39;] as $key => $option) {
            $memcached->setOption($key, $option);
        }
    }
    $memcachedStatus = $memcached->getVersion();

    if (! is_array($memcachedStatus)) {
        throw new RuntimeException(&#39;No Memcached servers added.&#39;);
    }

    if (in_array(&#39;255.255.255&#39;, $memcachedStatus) && count(array_unique($memcachedStatus)) === 1) {
        throw new RuntimeException(&#39;Could not establish Memcached connection.&#39;);
    }

    return $memcached;
}

?? ??? ????? ServiceProvider? ???? ??? ???? ???? ???. ??? ???? ??? ?????? ??? ?????. ??? ??????? ???? ?? ?? ???? ??? ???? ?? ?????.

??? '??'?? ??? ?????? ????? ?? ??? ???? ???, ??? ???, ???? ? ?? ??? ???? ??? ???? ?? ?????. ??? ???? ?????? ??? ?????.

Laravel? ?? ???? config/app.php ??? ?? ??? ??? ?????. ???? ???????? ??? ?? ??? ??? ???? ????. ?? ?? ? ???? ??? ??????. ?, ??? ??? ???? ?? ??? ??? ?? ?????.

?? ??? ???? IlluminateSupportServiceProvider ????? ?????. ???? ??? ?????? ?? ? ????? ? ?? ??? ????. ?? ????? ?? ? ?? ??? ????? ????? ?????. ??? ???, ?? ?? ?? ??? ????? ???? ????.

Artisan ?? make:provider:

php artisan make:provider MemcachedExtendServiceProvider

?? ??? ???? ??? ?? ?????. config/app.php ??. ? ???? ?? ??? ???? ??? ???? ??? ??? ???? ????. ????? ??? ??? ???? ??, ???, ?? ?? ?? Laravel ?? ?? ??? ?????.

??? ??? ????? ????? ?? ??? ?????.

&#39;providers&#39; => [
    SmartWiki\Providers\MemcachedExtendServiceProvider::class //
    在providers節(jié)點(diǎn)添加實(shí)現(xiàn)的provider
    ]

?? config/cache.php?? Memcached ??? ?????.

&#39;MemcachedExtend&#39; => [
    &#39;driver&#39; => &#39;MemcachedExtend&#39;,
    &#39;servers&#39; => [
        [
            &#39;host&#39; => env(&#39;MEMCACHED_EXTEND_HOST&#39;, &#39;127.0.0.1&#39;),
            &#39;port&#39; => env(&#39;MEMCACHED_EXTEND_PORT&#39;, 11211),
            &#39;weight&#39; => 100,
        ],
    ],
    &#39;options&#39; => [
        \Memcached::OPT_BINARY_PROTOCOL => true,
        \Memcached::OPT_COMPRESSION => false
    ]
]

?? ??? ??? ???? ?? ?? Session::extend? ???? ?? ???? ???? ???.

Session::extend(&#39;MemcachedExtend&#39;,function ($app){    
$memcached = $this->createMemcached($app);   
 return new MemcachedSessionHandler($memcached);
});

?? ?? ??? ???? .env? ??? ? ????. ?? ??? ??? ????.

<?php

namespace SmartWiki\Providers;

use Illuminate\Cache\Repository;
use Illuminate\Cache\MemcachedStore;
use Illuminate\Support\ServiceProvider;

use Cache;
use Session;
use Symfony\Component\HttpFoundation\Session\Storage\Handler\MemcachedSessionHandler;
use RuntimeException;

class MemcachedExtendServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap the application services.
     *
     * @return void
     */
    public function boot()
    {

        Cache::extend(&#39;MemcachedExtend&#39;, function ($app) {

            $memcached = $this->createMemcached($app);

            // 從配置文件中讀取緩存前綴
            $prefix = $app[&#39;config&#39;][&#39;cache.prefix&#39;];

            // 創(chuàng)建 MemcachedStore 對象
            $store = new MemcachedStore($memcached, $prefix);

            // 創(chuàng)建 Repository 對象,并返回
            return new Repository($store);
        });

        Session::extend(&#39;MemcachedExtend&#39;,function ($app){
            $memcached = $this->createMemcached($app);


            return new MemcachedSessionHandler($memcached);
        });
    }

    /**
     * Register the application services.
     *
     * @return void
     */
    public function register()
    {
        //
    }

    /**
     * 創(chuàng)建Memcached對象
     * @param $app
     * @return mixed
     */
    protected function createMemcached($app)
    {
        // 從配置文件中讀取 Memcached 服務(wù)器配置
        $servers = $app[&#39;config&#39;][&#39;cache.stores.MemcachedExtend.servers&#39;];


        // 利用 Illuminate\Cache\MemcachedConnector 類來創(chuàng)建新的 Memcached 對象
        $memcached = new \Memcached;

        foreach ($servers as $server) {
            $memcached->addServer(
                $server[&#39;host&#39;], $server[&#39;port&#39;], $server[&#39;weight&#39;]
            );
        }

        // 如果服務(wù)器上的 PHP Memcached 擴(kuò)展支持 SASL 認(rèn)證
        if (ini_get(&#39;memcached.use_sasl&#39;) && isset($app[&#39;config&#39;][&#39;cache.storess.MemcachedExtend.memcached_user&#39;]) && isset($app[&#39;config&#39;][&#39;cache.storess.MemcachedExtend.memcached_pass&#39;])) {

            // 從配置文件中讀取 sasl 認(rèn)證用戶名
            $user = $app[&#39;config&#39;][&#39;cache.storess.MemcachedExtend.memcached_user&#39;];

            // 從配置文件中讀取 sasl 認(rèn)證密碼
            $pass = $app[&#39;config&#39;][&#39;cache.storess.MemcachedExtend.memcached_pass&#39;];

            // 指定用于 sasl 認(rèn)證的賬號密碼
            $memcached->setSaslAuthData($user, $pass);
        }

        //擴(kuò)展
        if (isset($app[&#39;config&#39;][&#39;cache.stores.MemcachedExtend.options&#39;])) {
            foreach ($app[&#39;config&#39;][&#39;cache.stores.MemcachedExtend.options&#39;] as $key => $option) {
                $memcached->setOption($key, $option);
            }
        }
        $memcachedStatus = $memcached->getVersion();

        if (! is_array($memcachedStatus)) {
            throw new RuntimeException(&#39;No Memcached servers added.&#39;);
        }

        if (in_array(&#39;255.255.255&#39;, $memcachedStatus) && count(array_unique($memcachedStatus)) === 1) {
            throw new RuntimeException(&#39;Could not establish Memcached connection.&#39;);
        }

        return $memcached;
    }
}

SmartWikiCode


? ????? ??
? ?? ??? ????? ???? ??? ??????, ???? ?????? ????. ? ???? ?? ???? ?? ??? ?? ????. ???? ??? ???? ???? ??? ?? admin@php.cn?? ?????.

? AI ??

Undresser.AI Undress

Undresser.AI Undress

???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover

AI Clothes Remover

???? ?? ???? ??? AI ?????.

Video Face Swap

Video Face Swap

??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

???

??? ??

???++7.3.1

???++7.3.1

???? ?? ?? ?? ???

SublimeText3 ??? ??

SublimeText3 ??? ??

??? ??, ???? ?? ????.

???? 13.0.1 ???

???? 13.0.1 ???

??? PHP ?? ?? ??

???? CS6

???? CS6

??? ? ?? ??

SublimeText3 Mac ??

SublimeText3 Mac ??

? ??? ?? ?? ?????(SublimeText3)

???

??? ??

??? ????
1601
29
PHP ????
1502
276
???
PHP ???? ?? ??? ???? ?? PHP ?? ?? ?? ??? ?? ?? PHP ???? ?? ??? ???? ?? PHP ?? ?? ?? ??? ?? ?? Jul 25, 2025 pm 08:33 PM

PHP?? ?? ??? ???? ? ?? ?? ??? ????. 1. php.ini? ?? ??? ??; 2. ? ?? (? : Apache? Setenv ?? nginx? FastCGI_Param)? ??????. 3. PHP ?????? putenv () ??? ??????. ? ??? Php.ini? ????? ??? ???? ??? ???? ? ?? ??? ?? ???? ????? ???? Putenv ()? ?? ??? ?????. ?? ???? ?? ?? (? : php.ini ?? ? ?? ??)? ???? ????. ?? ?? ??? ??? ?? ??? ????? ???? ?? ????.

Laravel? ?? ???? ?????? Laravel? ?? ???? ?????? Jul 27, 2025 am 03:54 AM

Laravel? ?? ??? ?? ?? ??? ?? ?? ??? ???? ??? ??????. ?? ???? ?? ??? ????? ? ???? I/O ?? ? ?? ?? ??? ???? ???? ??? ?? ? ????. 1. ?? ????? ?? ? ? ???????? ??? ????? ?? ???? ??????. 2. ??? ? ??? ?? ? ? PhPartisAnconfig? ?? ???????. 3. ?? ??? ??? ??? ???? ?? ?? ?? ???? ???? ????. 4. ?? ?? ??? ???? ?? ??? ??? .env ??? ???? ?? ???????.

PHP ????? ?? ??? ??? ??? ?????? PHP ??? ????? ?? ? CI ?? ?? PHP ????? ?? ??? ??? ??? ?????? PHP ??? ????? ?? ? CI ?? ?? Jul 25, 2025 pm 08:54 PM

PHP ????? ?? ??? ??? ? ??? ??? CI (Continuous Integration) ????? ???? ? ????. 1. DockerFile? ???? ?? ???, ?? ??, ??? ?? ? ?? ??? ???? PHP ??? ?????. 2. Gitlabci? ?? CI/CD ??? ???? .gitlab-ci.yml ??? ?? ??, ??? ? ?? ??? ???? ?? ??, ??? ? ??? ?????. 3. PHPUNIT? ?? ??? ??? ??? ???? ?? ?? ? ???? ???? ????????. 4. Kubernetes? ?? ?? ?? ??? ???? ?? .yaml ??? ?? ?? ??? ?????. 5. Dockerfile ??? ? ??? ??? ??????

PHP ?? ??? ?? ?? ?? ?? PHP ?? ?? ? ?? ?? PHP ?? ??? ?? ?? ?? ?? PHP ?? ?? ? ?? ?? Jul 25, 2025 pm 06:51 PM

??? ?? ??? PHP ???? ?? ?? ??? ???? ?? ???????. RBAC (Role-Based Access Control) ??? ?? ???, ?? ? ??? ???? ??? ?? ?? ? ??? ?????. ?? ???? ??? ?????. 1. ???, ?? ? ??? ? ???? user_roles ? role_permissions? 3 ?? ?? ???; 2. $ user-> can ( 'edit_post')? ?? ???? ?? ?? ??? ?????. 3. ??? ???? ??? ??????. 4. ?? ??? ???? ?? ?? ?? ? ??? ? ???? ???? ?? ??? ? ?? ??? ?????. 5. ??? ??? ?? ?? ???? ?? ???? "??"? ??????.

Laravel Eloquent Scopes? ??????. Laravel Eloquent Scopes? ??????. Jul 26, 2025 am 07:22 AM

Laravel? eloquentscopes? ?? ??? ??? ??? ?????? ?? ?? ??? ????? ?????. 1. ?? ??? ???? ???? ???? ???? Post :: published (); 2. ??? ??? ?? ??? ???? ???? ?? ??? ?? ?? ?? ??? ???? ???? ??? ?????? ??? ???? ???????. 3. ????? ?? ?? ?? ??? ??? ?? ?? ??? ?? ? ? ??? ?? ? ? ?? ?? ??? ?????. 4. ?? ??? ? ??? ?? ???? ? ??? ? ?? ??, ?? ??, ?? ???? ? ?? ?????????.

Laravel?? ??? ??? ??? ??? Laravel?? ??? ??? ??? ??? Jul 26, 2025 am 08:58 AM

CreateAhelpers.phpfileInapp/helperswithCustOmFunctionsikeFormatPrice, isactiveroute, andisAdmin.2.addTheFileTothe "??"sectionOfcomposer.jsonUnderAutoLoad.3.runcomposerDump-AUTOLOADTOMAKETHINGTICTIONSGLOBELYAVAILABLE.4.USETHEHELPERFUNCUNTION

PHP PHP ?? ?? ? ?? ??? ?? ?? ???? ???? ?? PHP PHP ?? ?? ? ?? ??? ?? ?? ???? ???? ?? Jul 25, 2025 pm 08:48 PM

?? ?? ?? : ?? ????? PHP? ?? Error_Log ()? ??? ? ????. ????? ???? ??? ?? ??? ?????? ???? ?? ??? ? ?? ??? ???? ??? ?? ???, ??, ?? ? ?? ? ?? ?? ??? ???? ??? ??????. 2. ??? ?? ?? : ??? ??? ??? ??? ? ??? ?? ??? ??? ?? ??? ??? ??????? ??????. MySQL/PostgreSQL? ???? ??? ? ???? ??????. Elasticsearch Kibana? ? ???/? ???? ?????. ???, ??? ?? ? ??? ? ?? ??? ?? ??????. 3. ?? ? ?? ????? : ??, ???, ?? ? ??? ??? ??????. Kibana? ?? ????? PHP ??? ?? ?? ?????? ???? ???? ?????? ???? ??? ? ?? ??? ??? ? ????.

Laravel?? ?? ???? ???? ??? ?????? Laravel?? ?? ???? ???? ??? ?????? Aug 02, 2025 am 06:55 AM

??, ??, ?? ?? ? ?? ??? ???? ?? ??? ?? ? ?? ???? ?????. 2. ?? ???? ???? ?? ??? ??? SONGSTOMONY ? HASMANY ?? ??; 3. ?? ? ? ?? ? ?? ??? ????? (?? ???? ?? ??? ? ??). 4. ?? ? ?? ??? ???? ?? ??? ???? ?? ? ?? ??? ???? ?? ??? ?????. 5. ?? ???? ??? ?? (?? ??)? ???? ?? ????? ??????. 6. ?? ??? ?? ??? ???? Laravel Signature URL? ???? ??? ??????. 7. ? ?? ?? ? ? ?? ??? ?? ?? ??? ?? ??? ?????. ?????? ??, ?? ?? ??? ??????????.

See all articles