npm install -D tailwindcss postcss autoprefixer We just need to install postcss and autoprefixer too. Tailwind requires the least amount of effort. Now that we have our fresh install, we can go ahead and add Inertia.js, Vue.js and Tailwind CSS. If the laravel new awesome-app returns laravel: command not found make sure that you have you're Composer's vendor bin directory in $PATH (see above). Npm install #installs all the dependencies composer global require laravel/installer Making sure we are in the desired folder we're going to require the Laravel's installer globally and then use it to create a new app called " awesome-app" (this will automatically create the folder with the same name). Please note that I'm using Laravel 8 and PHP 8.0. I'm using Windows 11 + WSL2 running Ubuntu and I prefer the Laravel installer, so I need to run the following commands one by one. To install Laravel you can use Laravel Sail, which will boot up a Docker container, or you can use the old fashioned Laravel installer. Now npm should be available globally: npm -v #retuns the current version To install it on Ubuntu, we just use the following lines: sudo apt update We will also need NodeJS to use the node package manager aka npm. Now save and run source ~/.config/.bashrc to refresh the configuration. So nano ~/.config/.bashrc and add the path to the Composer's vendor bin directory at the end of the file: export PATH=~/.config/composer/vendor/bin:$PATH You can find more info about this in the official Laravel documentation here.įor me, on WSL2 Ubuntu on Windows 11, the easiest way to do it is to add the path to. One more thing we need to do is to add our Composer's vendor bin directory in $PATH. We've just installed Composer and moved it into our /usr/local/bin directory, so now the composer command will be available globally in our terminal. Php composer-setup.php -install-dir=/usr/local/bin If you already have Composer installed, you can skip the following chunk of commands: php -r "copy('', 'composer-setup.php') " I'll briefly go over how to install Composer and NPM. We'll be using PHP 8, so make sure you have that installed, Composer and NPM. Inertia.js and Tailwind CSS are just two more tools that were added to the book that are really mind blowing.īefore we dive in deep, we just want to make sure we have all the tools we need. So what I'm trying to point out is that Laravel will always try to adopt and support new cool JS frameworks or any other tool that's really a gamechanger. So even today, even if Laravel has scaffoldings for both JS frameworks, I'd always pick Vue over React, just because it is easier. He stated in a tweet many years ago that Vue was actually easier to learn compared to React. The beauty of this php framework is not only the ease of writing code but the community behind it which always find new ways to improve the code, develops new packages and also pushes the integration with other awesome frameworks.įor example, if it wasn't for Laravel's creator, Taylor Otwell, I think Vue wouldn't have been so popular today. I've been using it since version 4 and today we celebrate the launch of the 9th version. Laravel is by far the most popular open source PHP framework out there. Laravel 10 Import Export Excel to Database Example - ItSolutionStuff.NOTICE: This guide was written using Laravel 8, but it 100% works on Laravel 9. In Last step, let's create (resources/views/) for layout and we will write design code here and put following code: Route::post('users-import', 'import')->name('users.import') Route::get('users-export', 'export')->name('users.export') so open your "routes/web.php" file and add following route. In this step, we need to create routes for list of users, import users and export users. Php artisan make:controller UserController so first let's create controller by following command and update code on it. In this step, we will create UserController with index(), export() and import() method. Php artisan make:export UsersExport -model=User So you have to run following command and change following code on that file: So it would be great way to create new Export class. Maatwebsite 3 version provide way to built export class and we have to use in controller. You can download demo csv file from here: Demo CSV File. Php artisan make:import UsersImport -model=User So it would be great way to create new Import class. In maatwebsite 3 version provide way to built import class and we have to use in controller. In this step, we will create some dummy records for users table, so we can export them with that users. Read Also: Laravel 10 CRUD Application Example Tutorial
0 Comments
Leave a Reply. |