This Laravel application demonstrates how to use the Iterator pattern to fetch and process paginated stock market data from a simulated API (JSON files in this case). It's designed to handle scenarios where data is retrieved in chunks, and provides an efficient way to iterate over potentially large datasets.
-
Clone the repository:
git clone <repository-url> cd stock-api-iterator
-
Install composer dependencies
composer install
-
Copy
.env.exampleto.envand add your APP_URL:cp .env.example .envSet the
APP_URLtohttp://localhostin your.envfile. -
Install Sail:
composer require laravel/sail --dev php artisan sail:install
- Select 0
pgsql - Select ENTER to finish installation
-
Start Sail:
./vendor/bin/sail up -d
-
Generate an app key:
./vendor/bin/sail artisan key:generate
-
Run Migrations
./vendor/bin/sail artisan migrate
-
Install Node Packages
npm install
-
Run the development server for the front-end:
npm run dev
-
Access your Application via http://localhost
Visit /stocks/{symbol} to see stock data for the specified ticker symbol. Example: /stocks/IBM.
Visit /quote/{symbol} to see quote data for the specified ticker symbol. Example: /quote/IBM.