Karena jawabannya sudah saya temukan, jadi saya akan jawab sendiri saya menggunakan laravel Storage simpan file pada folder storage/app (misalnya storage/app/gambar.jpg) lalu buat route ke file tersebut (misalnya localhost/gambar) Show
$image = Storage::get("gambar.jpg"); return response($image, 200)->header("Content-type", "image/jpg"); Laravel Valet is a development environment for macOS minimalists. Laravel Valet configures your Mac to always run Nginx in the background when your machine starts. Then, using DnsMasq, Valet proxies all requests on the In other words, Valet is a blazing fast Laravel development environment that uses roughly 7 MB of RAM. Valet isn't a complete replacement for Sail or Homestead, but provides a great alternative if you want flexible basics, prefer extreme speed, or are working on a machine with a limited amount of RAM. Out of the box, Valet support includes, but is not limited to: However, you may extend Valet with your own . Installation
To get started, you first need to ensure that Homebrew is up to date using the 0 command:Next, you should use Homebrew to install PHP: After installing PHP, you are ready to install the Composer package manager. In addition, you should make sure the 1 directory is in your system's "PATH". After Composer has been installed, you may install Laravel Valet as a global Composer package:
Finally, you may execute Valet's 2 command. This will configure and install Valet and DnsMasq. In addition, the daemons Valet depends on will be configured to launch when your system starts:Once Valet is installed, try pinging any 4. If Valet is installed correctly you should see this domain responding on 5.Valet will automatically start its required services each time your machine boots. PHP VersionsValet allows you to switch PHP versions using the 6 command. Valet will install the specified PHP version via Homebrew if it is not already installed:You may also create a 7 file in the root of your project. The 7 file should contain the PHP version the site should use:Once this file has been created, you may simply execute the 9 command and the command will determine the site's preferred PHP version by reading the file.
DatabaseIf your application needs a database, check out DBngin. DBngin provides a free, all-in-one database management tool that includes MySQL, PostgreSQL, and Redis. After DBngin has been installed, you can connect to your database at 5 using the 1 username and an empty string for the password.Resetting Your InstallationIf you are having trouble getting your Valet installation to run properly, executing the 2 command followed by 3 will reset your installation and can solve a variety of problems. In rare cases, it may be necessary to "hard reset" Valet by executing 4 followed by 3.Upgrading ValetYou may update your Valet installation by executing the 2 command in your terminal. After upgrading, it is good practice to run the 3 command so Valet can make additional upgrades to your configuration files if necessary.Serving SitesOnce Valet is installed, you're ready to start serving your Laravel applications. Valet provides two commands to help you serve your applications: 8 and 9.The // Set $_SERVER['key'] to "value" for the laravel.test site... // Set $_SERVER['key'] to "value" for all sites...8 CommandThe 8 command registers a directory on your machine that contains your applications. Once the directory has been "parked" with Valet, all of the directories within that directory will be accessible in your web browser at 2:That's all there is to it. Now, any application you create within your "parked" directory will automatically be served using the 2 convention. So, if your parked directory contains a directory named "laravel", the application within that directory will be accessible at 4. In addition, Valet automatically allows you to access the site using wildcard subdomains ( 5).The // Set $_SERVER['key'] to "value" for the laravel.test site... // Set $_SERVER['key'] to "value" for all sites...9 CommandThe 9 command can also be used to serve your Laravel applications. This command is useful if you want to serve a single site in a directory and not the entire directory:Once an application has been linked to Valet using the 9 command, you may access the application using its directory name. So, the site that was linked in the example above may be accessed at 4. In addition, Valet automatically allows you to access the site using wildcard sub-domains ( 5).If you would like to serve the application at a different hostname, you may pass the hostname to the 9 command. For example, you may run the following command to make an application available at 2:Of course, you may also serve applications on subdomains using the 9 command:You may execute the 4 command to display a list of all of your linked directories:The 5 command may be used to destroy the symbolic link for a site:Securing Sites With TLSBy default, Valet serves sites over HTTP. However, if you would like to serve a site over encrypted TLS using HTTP/2, you may use the 6 command. For example, if your site is being served by Valet on the 7 domain, you should run the following command to secure it:To "unsecure" a site and revert back to serving its traffic over plain HTTP, use the 8 command. Like the 6 command, this command accepts the hostname that you wish to unsecure:Serving A Default SiteSometimes, you may wish to configure Valet to serve a "default" site instead of a 0 when visiting an unknown 1 domain. To accomplish this, you may add a 2 option to your 3 configuration file containing the path to the site that should serve as your default site:
Per-Site PHP VersionsBy default, Valet uses your global PHP installation to serve your sites. However, if you need to support multiple PHP versions across various sites, you may use the 4 command to specify which PHP version a particular site should use. The 4 command configures Valet to use the specified PHP version for the site located in your current working directory:If your site name does not match the name of the directory that contains it, you may specify the site name using the 6 option:For convenience, you may use the 7, 8, and 9 commands to proxy calls to the appropriate PHP CLI or tool based on the site's configured PHP version:You may execute the 0 command to display a list of all of your isolated sites and their PHP versions:To revert a site back to Valet's globally installed PHP version, you may invoke the 1 command from the site's root directory:Sharing SitesValet even includes a command to share your local sites with the world, providing an easy way to test your site on mobile devices or share it with team members and clients. Sharing Sites Via NgrokTo share a site, navigate to the site's directory in your terminal and run Valet's 2 command. A publicly accessible URL will be inserted into your clipboard and is ready to paste directly into your browser or share with your team:To stop sharing your site, you may press 3. Sharing your site using Ngrok requires you to create an Ngrok account and setup an authentication token.
Sharing Sites Via ExposeIf you have Expose installed, you can share your site by navigating to the site's directory in your terminal and running the 5 command. Consult the Expose documentation for information regarding the additional command-line parameters it supports. After sharing the site, Expose will display the sharable URL that you may use on your other devices or amongst team members:To stop sharing your site, you may press 3.Sharing Sites On Your Local NetworkValet restricts incoming traffic to the internal 5 interface by default so that your development machine isn't exposed to security risks from the Internet.If you wish to allow other devices on your local network to access the Valet sites on your machine via your machine's IP address (eg: 8), you will need to manually edit the appropriate Nginx configuration file for that site to remove the restriction on the 9 directive. You should remove the 0 prefix on the 9 directive for ports 80 and 443.If you have not run 2 on the project, you can open up network access for all non-HTTPS sites by editing the 3 file. However, if you're serving the project site over HTTPS (you have run 2 for the site) then you should edit the 5 file.Once you have updated your Nginx configuration, run the 6 command to apply the configuration changes.Site Specific Environment VariablesSome applications using other frameworks may depend on server environment variables but do not provide a way for those variables to be configured within your project. Valet allows you to configure site specific environment variables by adding a 7 file within the root of your project. This file should return an array of site / environment variable pairs which will be added to the global 8 array for each site specified in the array:
Proxying ServicesSometimes you may wish to proxy a Valet domain to another service on your local machine. For example, you may occasionally need to run Valet while also running a separate site in Docker; however, Valet and Docker can't both bind to port 80 at the same time. To solve this, you may use the 9 command to generate a proxy. For example, you may proxy all traffic from 0 to 1:
You may remove a proxy using the 2 command:
You may use the 3 command to list all site configurations that are proxied:Custom Valet DriversYou can write your own Valet "driver" to serve PHP applications running on a framework or CMS that is not natively supported by Valet. When you install Valet, a 4 directory is created which contains a 5 file. This file contains a sample driver implementation to demonstrate how to write a custom driver. Writing a driver only requires you to implement three methods: 6, 7, and 8.All three methods receive the 9, *.test 0, and *.test 1 values as their arguments. The 9 is the fully qualified path to the site being served on your machine, such as *.test 3. The *.test 0 is the "host" / "site name" portion of the domain (*.test 5). The *.test 1 is the incoming request URI (*.test 7).Once you have completed your custom Valet driver, place it in the 4 directory using the *.test 9 naming convention. For example, if you are writing a custom valet driver for WordPress, your filename should be 00.Let's take a look at a sample implementation of each method your custom Valet driver should implement. The
|