728x90

PHP 42

autoloader 사용법 (PSR-4)

autoloader는 include 또는 require 중복을 없애고 class 폴더를 쉽게 가져오기 위함여기서 경로만 수정해주면 된다. /src/autoloader.php  index.php require_once './../Classes/ZipStream/src/autoloader.php';try { // 객체 생성 테스트 $test = new \ZipStream\src\TestClass(); echo $test->sayHello(); // 메서드 호출} catch (Throwable $e) { // 오류 발생 시 echo "Error: " . $e->getMessage();}  ZipStream/src/TestClass.php

PHP 2024.12.04

라라벨 2일 차 (@vite, css에서 image 불러오기)

1. index.blade.php에서 img src로 불러오는건 public이든 resources든 상관이 없다 DOCTYPE html> Document @vite(['resources/css/index.css','resources/js/script.js']) Hello world 2. 하지만 css에서 images를 불러오려면 public이아닌 resources에서 가능하며 경로는 절대경로가 아닌 상대 경로로 지정해주어야 css가 나온다. index.css body{ margin:0; /* 원래 기본 background는 margin이 8이다. */ background-image: url("../images/background.jpg"); background-repeat: no-repeat; /* 공간..

PHP/Laravel 2024.02.26

라라벨 1일 차 (@vite, js, css 불러오기)

오늘은 라라벨 설치부터 vite 사용하는 법까지 1. 원래는public이 기본 하위 디렉터리라 public 폴더 안에 js, css를 넣는 것이 맞다 (이럴경우 asset{{ }} 사용) 2. vite나 laravel mix를 통해 public, asset{{ }}없이 resources에서 사용할 수 있다 npm으로 설치 index.blade.php DOCTYPE html> Document Hello world @vite(['resources/css/index.css']) vite.config.js import { defineConfig } from 'vite'; import laravel from 'laravel-vite-plugin'; export default defineConfig({ plugin..

PHP/Laravel 2024.02.20
728x90