Saturday, March 4, 2023

Valet commands cheet sheets

Starting and Stopping Valet

valet start - Start Valet

valet stop - Stop Valet

valet restart - Restart Valet

Managing Sites

valet park - Map the current directory to a Valet site

valet link [name] - Create a symbolic link for a site

valet secure - Secure a site with HTTPS

valet share - Share a site publicly via ngrok

valet unlink [name] - Remove a symbolic link for a site

valet unsecure - Remove HTTPS from a site

valet forget [name] - Remove a site from Valet

Viewing Logs

valet logs - View the Nginx and PHP error logs

Miscellaneous

valet paths - Display the paths used by Valet

valet open - Open the current site in your default web browser

valet list - List all sites that are mapped in Valet

valet version - Display the current version of Valet

I hope you find this cheet sheet helpful! Let me know if you have any other questions. 

Use multiple php version using valet

 To use multiple PHP versions with Valet on a Mac, you will need to follow these steps:

Install the desired versions of PHP using Homebrew. For example, to install PHP 7.4 and 8.0:

brew install php@7.4

brew install php@8.0

Install Valet if you haven't already:

composer global require laravel/valet

valet install

Install Valet's PHP switcher plugin:

valet install

valet use php@7.4

Create a symbolic link for each version of PHP that you installed. For example:

sudo ln -s /usr/local/opt/php@7.4/bin/php /usr/local/bin/php74

sudo ln -s /usr/local/opt/php@8.0/bin/php /usr/local/bin/php80

Run the following command to add the newly created symbolic links to your $PATH environment variable:


echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bash_profile

source ~/.bash_profile

Restart Valet:

valet restart

You can now switch between PHP versions using the valet use command. For example, to use PHP 7.4:

valet use php@7.4

To switch back to PHP 8.0:


valet use php@8.0

Note that you will need to install any required PHP extensions for each version of PHP that you use. You can install extensions using Homebrew or by manually compiling and installing them.

Setup mssql using valet in MAC

To set up MS SQL in Valet on a Mac, you will need to follow these steps:

Install the required PHP extensions:

brew tap exolnet/homebrew-deprecated

For php 7.4

brew install php@7.4-mssql

For php 8.0

brew install php@8.0-mssql

Install the SQL Server driver for PHP:

pecl install sqlsrv pdo_sqlsrv

Once the SQL Server driver is installed, add the following lines to your PHP configuration file:

extension=sqlsrv.so

extension=pdo_sqlsrv.so

Install the Microsoft ODBC Driver for SQL Server:

brew tap microsoft/mssql-release https://github.com/Microsoft/homebrew-mssql-release

brew install msodbcsql17

Configure Valet to use MS SQL by adding the following lines to your Valet configuration file ~/.config/valet/config.json:

json

Copy code

"mssql": {

     "port": "1433",

     "dump": false

 }

Restart Valet and you should now be able to use MS SQL in your PHP applications. To test, create a new Laravel project and try connecting to your MS SQL database.


Note: Make sure that your MS SQL server is configured to allow remote connections if you are using a remote server. 

for mac add this path to zshrc file

export PATH="$HOME/.composer/vendor/bin:$PATH"