Colombia recently deployed 3,000 troops along its border with Venezuela to control the influx of more than 250,000 refugees fleeing that failing socialist country. Brazil declared a state of social emergency, deployed 100 more troops to the border, established new checkpoints, and a field hospital to deal with the more than 60,000 Venezuelan refugees who have crossed over into the northern part of the country. That is likely the first of many actions by Colombia, Brazil, and other neighboring governments to deal with this mess.

Since the rise of Hugo Chavez’s Bolivarian socialism two decades ago, 4 million Venezuelans have fled the country — including 1.2 million just in the last two years. The scale of Venezuela’s emigration is quickly approaching the 5.5 million Syrians who fled Syria during its civil war. A poll conducted by the Venezuelan firm Consultores21 found that 40 percent of respondents wanted to flee the country last December. If realized, that would mean almost 13 million emigrants, dwarfing the number who have fled Syria so far during its civil war.

The world’s handling of the Syrian refugees was hit-or-miss, providing lessons for those attempting to tackle the Venezuelan crisis — beyond declaring states of emergency and deploying troops. Venezuelan refugees can be integrated at a minimal cost to taxpayers, international aid organizations, and charities, but only if governments follow a few simple rules of thumb.

The first is to grant Venezuelans work permits as fast as possible. Peru created a one-year renewable work and residency permit for 11,000 Venezuelans, although more than 30,000 have applied. Just last year, 149,000 entered Peru. Brazil also created a temporary residence permit for the rising number of Venezuelans.

These permits are great starts, but need to be available to all Venezuelans who are fleeing the collapse of the Bolivarian socialist state. The sooner that Venezuelans can work and support themselves, the sooner the burden on local government services will lessen. Otherwise, Venezuelans will continue to be charity cases or work in the informal sector. This problem happened in many European countries, which invited Syrian asylum seekers but then made it impossible for them to work legally or start businesses. Jordan and Turkey reduced both problems by eventually granting work permits to Syrians, with generally positive effects on the local economy.

Colombia initially created a special work and residency permit for Venezuelans called the PEP, with an eventual goal of granting them to 150,000 of the 750,000 to 2 million Venezuelans living in the country. Since then, Colombian President Juan Manuel Santos has reversed policy and restricted the issuance of new work visas to Venezuelans in an effort to gain “more control and more security at borders.” Like in Europe, the main effect of these new restrictions will be more dangerous illegal crossings and less economic integration.

Second, keeping order is paramount. Voters in host countries could turn against the Venezuelan refugees if they cross the border in a chaotic way, overwhelm local social services, and turn to crime. Neighboring countries should thus monitor the security situation closely and encourage Venezuelans to move away from the border regions and to major cities or economically growing regions as fast as possible, just as Brazil has started doing.

Third, countries from outside of the region should start welcoming Venezuelans. About 59,000 Venezuelans sought asylum in the United States since 2014, accounting for 12 percent of all asylum applicants. About 30,000 Venezuelans sought asylum just last year, up about 34-fold from 2013. President Trump more than halved the number of refugees and added Venezuela to his list of travel ban countries — but he might make a special exception for Venezuelans due to political self-interest. Since the Venezuelans are fleeing a collapsing socialist state, many of them will be attracted to the Republican Party’s rhetorical anti-socialism much as previous waves of Cuban, Vietnamese, and Chinese immigrants were.

Countries outside of South America and the Western Hemisphere could also welcome Venezuelans. Almost 10,000 Venezuelans filed for asylum in Spain last year. Since citizens of both countries speak the same language, integration in the Spanish labor market would be relatively easy.

Venezuelan President Nicolás Maduro has crushed his political opposition and the democratic process while the economy continues to collapse, so the exodus will continue. The Syrian experience shows that work permits are key to helping the refugees and host governments cope with the inflow. Maduro will fall someday, but in the meantime it’s in everyone’s best interests if the Venezuelans who flee are able to work legally.