Laravel Türkiye Discord Kanalı Forumda kod paylaşılırken dikkat edilmesi gerekenler!Birlikte proje geliştirmek ister misiniz?

onurzdgn

  • 17 Şub
  • 23 May 2024 tarihinde katıldı
  • 0 en iyi yanıt
  • Nedenini tam anlamadım ama sorunu çözdüm. Diğer iki projem otomatik bağlanırken Laravel 11 ile olan projem otomatik bağlanmadı. 127.0.0.1 yerine uzak bağlantı linkini vermem gerekti

  • mgsmus Denedim malesef sonuç yine hata verdi. Hata:
    `
    In Connection.php line 813:


    SQLSTATE[HY000] [2002] Connection refused (Connection: mysql, SQL: select table_name as name, (data_length + index_length) as si
    ze
    , table_comment as comment, engine as engine, table_collation as collation from information_schema.tables where table_sche
    ma = 'laravel' and table_type in ('BASE TABLE', 'SYSTEM VERSIONED') order by table_name)


    In Connector.php line 65:


    SQLSTATE[HY000] [2002] Connection refused
    `

    • aeneas Bir kaç kez kontrol ettim. Ayrıca .env dosyasında olmasa dahi bağlanıyor bir projemde silip denedim aynı hatayı veriyor.

      • Merhabalar Laravel 11 ile sorunsuz bir şekilde bir proje oluşturdum. Bu projemi diğer iki projem gibi (onlar laravel 10) digital ocean'da yaınlamak istedim ancak bazı hatalar alıyorum. Ekrana yazan:
        SQLSTATE[HY000] [2002] Connection refused (Connection: mysql, SQL: select * fromsessionswhereid= cOtRIjSEYAvXtvNNFckXenpVREw0YOZMSYlmbhsy limit 1)

        Log da yazan ise:
        [2024-07-25 06:55:53] production.ERROR: SQLSTATE[HY000] [2002] Connection refused (Connection: mysql, SQL: select table_name asname, (data_length + index_length) assize, table_comment ascomment, engine asengine, table_collation ascollationfrom information_schema.tables where table_schema = 'laravel' and table_type in ('BASE TABLE', 'SYSTEM VERSIONED') order by table_name) {"exception":"[object] (Illuminate\\Database\\QueryException(code: 2002): SQLSTATE[HY000] [2002] Connection refused (Connection: mysql, SQL: select table_name asname, (data_length + index_length) assize, table_comment ascomment, engine asengine, table_collation ascollationfrom information_schema.tables where table_schema = 'laravel' and table_type in ('BASE TABLE', 'SYSTEM VERSIONED') order by table_name) at /workspace/vendor/laravel/framework/src/Illuminate/Database/Connection.php:813)
        [stacktrace]

        Veri tabanı bilgilerimin doğruluğundan eminim

      • BoraN7 Trust Proxies olduğunu sanmıyorum çünkü blade şablonu ile çalıştı

      • mgsmus
        `
        public function upload($photo)
        {
        if ($this->controlApiToken()->getStatusCode() !== 200) {
        return response()->json('Cloudflare API key is invalid', 500);
        }
        // Download photo to Cloudflare


            $tmpUrl = $this->createTmpUrl();
            
            if ($tmpUrl === false) {
                return response()->json(['error' => 'Temporary URL could not be created'], 500);
            }
            
            $client = new Client();
        
            try {
                $response = $client->request('POST', $tmpUrl, [
                    'multipart' => [
                        [
                            'name' => 'file',
                            'contents' => Psr7\Utils::tryFopen($photo->getRealPath(), 'r'),
                        ],
                    ]
                ]);
        
                // If the request is successful, get the response
                $result = json_decode($response->getBody(), true);
                $photoId = $result['result']['id'];
        
                return response()->json(['photoId' => $photoId], 200);
            } catch (\Exception $e) {
                // If the request fails, show the error message
                echo $e->getMessage();
                return false;
            }
        }

        `

        Bu şekilde bir fonksiyon yazdım bu fonksiyondan önce api token geçerli mi diye kontrol ediyorum sonrasında geçici url oluşturuyorum ardından resmi kayıt ediyorum.

      • Laravel 10 ve Livewire 3 ile DigitalOcean'ın App platformundan CloudFlare'e fotoğraf yüklemeye çalışıyorum. Bunun için bir servis yazdım ve bu servis api'si CloudFlare'nin api dokümanına göre yazıldı. Projem localde sorunsuz çalışıyor ama üretim sunucumda "Dosya Seç" butonuna basıp, dosyayı işaretleyip "Aç" butonuna bastığımda hata veriyor. Konsola baktığımda "Kaynak yüklenemedi: sunucu 401 () durumuyla yanıt verdi" hatasını görüyorum. Bunda sorun ne olabilir ve nasıl çözebilirim? Sorun DigitalOcean'ın "livewire-tmp" dosyası oluşturamamasından diye tahmin ediyorum.